Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pseries: extract host bridge from pci_bus prior to bus removal

The pci_bus->bridge reference may no longer be valid after
pci_bus_remove() resulting in passing a bad value to device_unregister()
for the associated bridge device.

Store the host_bridge reference in a separate variable prior to
pci_bus_remove().

Fixes: 7340056567e3 ("powerpc/pci: Reorder pci bus/bridge unregistration during PHB removal")
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210211182435.47968-1-tyreld@linux.ibm.com

authored by

Tyrel Datwyler and committed by
Michael Ellerman
38d0b1c9 0751fdf2

+3 -1
+3 -1
arch/powerpc/platforms/pseries/pci_dlpar.c
··· 50 50 int remove_phb_dynamic(struct pci_controller *phb) 51 51 { 52 52 struct pci_bus *b = phb->bus; 53 + struct pci_host_bridge *host_bridge = to_pci_host_bridge(b->bridge); 53 54 struct resource *res; 54 55 int rc, i; 55 56 ··· 77 76 /* Remove the PCI bus and unregister the bridge device from sysfs */ 78 77 phb->bus = NULL; 79 78 pci_remove_bus(b); 80 - device_unregister(b->bridge); 79 + host_bridge->bus = NULL; 80 + device_unregister(&host_bridge->dev); 81 81 82 82 /* Now release the IO resource */ 83 83 if (res->flags & IORESOURCE_IO)