• Lukas Wunner's avatar
    PCI: Fix BUG on device attach failure · 1e398eae
    Lukas Wunner authored
    Previously when pci_bus_add_device() called device_attach() and it returned
    a negative value, we emitted a WARN but carried on.
    
    Commit ab1a187b ("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: ab1a187b ("PCI: Check device_attach() return value always")
    Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    1e398eae
bus.c 9.72 KB