From 2a8bc957a7e211731b35fc9c96cc9e46558424ba Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 29 Apr 2015 21:59:46 +0200 Subject: [PATCH] PCI: register and active bridge device before proceeding to scan The bridge device needs to be registered and activated before the scanning can proceed, as the bridge is the parent for other devices. This fixes a NULL ptr derefernce when scanning PCI hierarchies with bridges behind bridges. Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- drivers/pci/pci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 40e0fe7f8..470ea664e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -371,11 +371,15 @@ unsigned int pci_scan_bus(struct pci_bus *bus) list_add_tail(&child_bus->node, &bus->children); dev->subordinate = child_bus; + /* activate bridge device */ + pci_register_device(dev); + + /* scan pci hierarchy behind bridge */ prescan_setup_bridge(dev); pci_scan_bus(child_bus); postscan_setup_bridge(dev); - /* first activate bridge then all devices on it's bus */ - pci_register_device(dev); + + /* finally active all devices behind the bridge */ list_for_each_entry(dev, &child_bus->devices, bus_list) if (!dev->subordinate) pci_register_device(dev);