Skip to content

Commit 3735459

Browse files
committed
PCI/MSI: Destroy sysfs before freeing entries
free_msi_irqs() frees the MSI entries before destroying the sysfs entries which are exposing them. Nothing prevents a concurrent free while a sysfs file is read and accesses the possibly freed entry. Move the sysfs release ahead of freeing the entries. Fixes: 1c51b50 ("PCI/MSI: Export MSI mode using attributes, not kobjects") Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/87sfw5305m.ffs@tglx
1 parent f21082f commit 3735459

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/pci/msi.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ static void free_msi_irqs(struct pci_dev *dev)
368368
for (i = 0; i < entry->nvec_used; i++)
369369
BUG_ON(irq_has_action(entry->irq + i));
370370

371+
if (dev->msi_irq_groups) {
372+
msi_destroy_sysfs(&dev->dev, dev->msi_irq_groups);
373+
dev->msi_irq_groups = NULL;
374+
}
375+
371376
pci_msi_teardown_msi_irqs(dev);
372377

373378
list_for_each_entry_safe(entry, tmp, msi_list, list) {
@@ -379,11 +384,6 @@ static void free_msi_irqs(struct pci_dev *dev)
379384
list_del(&entry->list);
380385
free_msi_entry(entry);
381386
}
382-
383-
if (dev->msi_irq_groups) {
384-
msi_destroy_sysfs(&dev->dev, dev->msi_irq_groups);
385-
dev->msi_irq_groups = NULL;
386-
}
387387
}
388388

389389
static void pci_intx_for_msi(struct pci_dev *dev, int enable)

0 commit comments

Comments
 (0)