Skip to content

Commit a1216e6

Browse files
Ganesh Goudarmpe
authored andcommitted
powerpc/eeh: avoid possible crash when edev->pdev changes
If a PCI device is removed during eeh_pe_report_edev(), edev->pdev will change and can cause a crash, hold the PCI rescan/remove lock while taking a copy of edev->pdev->bus. Signed-off-by: Ganesh Goudar <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 1a14150 commit a1216e6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/powerpc/kernel/eeh_pe.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe)
849849
{
850850
struct eeh_dev *edev;
851851
struct pci_dev *pdev;
852+
struct pci_bus *bus = NULL;
852853

853854
if (pe->type & EEH_PE_PHB)
854855
return pe->phb->bus;
@@ -859,9 +860,11 @@ struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe)
859860

860861
/* Retrieve the parent PCI bus of first (top) PCI device */
861862
edev = list_first_entry_or_null(&pe->edevs, struct eeh_dev, entry);
863+
pci_lock_rescan_remove();
862864
pdev = eeh_dev_to_pci_dev(edev);
863865
if (pdev)
864-
return pdev->bus;
866+
bus = pdev->bus;
867+
pci_unlock_rescan_remove();
865868

866-
return NULL;
869+
return bus;
867870
}

0 commit comments

Comments
 (0)