9
0
Fork 0

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 <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Lucas Stach 2015-04-29 21:59:46 +02:00 committed by Sascha Hauer
parent 92207cde49
commit 2a8bc957a7
1 changed files with 6 additions and 2 deletions

View File

@ -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);