Patchwork [2/3] msi: always unregister ->msi_kset within free_msi_irqs()

login
register
mail settings
Submitter Veaceslav Falico
Date Sept. 17, 2013, 1:47 a.m.
Message ID <1379382464-7920-3-git-send-email-vfalico@redhat.com>
Download mbox | patch
Permalink /patch/275351/
State Changes Requested
Headers show

Comments

Veaceslav Falico - Sept. 17, 2013, 1:47 a.m.
Currently we create and populate ->msi_kset while allocating irqs in
populate_msi_sysfs(), however if it fails and/or we want to free the
entries - we don't always remove it, and we might have problems if we've
failed to allocate irqs and try it again.

To fix that, move the unregister part to free_msi_irqs() and remove already
existing ones.

CC: Bjorn Helgaas <bhelgaas@google.com>
CC: linux-pci@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
 drivers/pci/msi.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 14bf578..68da921 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -388,6 +388,9 @@  static void free_msi_irqs(struct pci_dev *dev)
 		list_del(&entry->list);
 		kfree(entry);
 	}
+
+	kset_unregister(dev->msi_kset);
+	dev->msi_kset = NULL;
 }
 
 static struct msi_desc *alloc_msi_entry(struct pci_dev *dev)
@@ -917,8 +920,6 @@  void pci_disable_msi(struct pci_dev *dev)
 
 	pci_msi_shutdown(dev);
 	free_msi_irqs(dev);
-	kset_unregister(dev->msi_kset);
-	dev->msi_kset = NULL;
 }
 EXPORT_SYMBOL(pci_disable_msi);
 
@@ -1015,8 +1016,6 @@  void pci_disable_msix(struct pci_dev *dev)
 
 	pci_msix_shutdown(dev);
 	free_msi_irqs(dev);
-	kset_unregister(dev->msi_kset);
-	dev->msi_kset = NULL;
 }
 EXPORT_SYMBOL(pci_disable_msix);