[PATCH 1/3] PCI: register and active bridge device before proceeding to scan

Lucas Stach dev at lynxeye.de
Wed Apr 29 12:59:46 PDT 2015


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 <dev at lynxeye.de>
---
Please apply to master, as this fixes a crash when activating
PCI support on the GW54xx board.
---
 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 40e0fe7..470ea66 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);
-- 
2.1.0




More information about the barebox mailing list