Skip to content

Commit 1e398ea

Browse files
l1kbjorn-helgaas
authored andcommitted
PCI: Fix BUG on device attach failure
Previously when pci_bus_add_device() called device_attach() and it returned a negative value, we emitted a WARN but carried on. Commit ab1a187 ("PCI: Check device_attach() return value always"), introduced in Linux 4.6-rc1, changed this to unwind all steps preceding device_attach() and to not set dev->is_added = 1. The latter leads to a BUG if pci_bus_add_device() was called from pci_bus_add_devices(). Fix by not recursing to a child bus if device_attach() failed for the bridge leading to it. This can be triggered by plugging in a PCI device (e.g. Thunderbolt) while the system is asleep. The system locks up when woken because device_attach() returns -EPROBE_DEFER. Fixes: ab1a187 ("PCI: Check device_attach() return value always") Signed-off-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 67e6587 commit 1e398ea

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/pci/bus.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ void pci_bus_add_devices(const struct pci_bus *bus)
324324
}
325325

326326
list_for_each_entry(dev, &bus->devices, bus_list) {
327-
BUG_ON(!dev->is_added);
327+
/* Skip if device attach failed */
328+
if (!dev->is_added)
329+
continue;
328330
child = dev->subordinate;
329331
if (child)
330332
pci_bus_add_devices(child);

0 commit comments

Comments
 (0)