From: Sinan Kaya Date: Tue, 27 Feb 2018 20:14:08 +0000 (-0600) Subject: PCI: Protect restore with device lock to be consistent X-Git-Tag: Ubuntu-5.10.0-12.13~8102^2~13^2~9 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=cb5e0d060fb1f3136e96acecbd4001a7f0cbac94;p=mirror_ubuntu-hirsute-kernel.git PCI: Protect restore with device lock to be consistent Commit b014e96d1abb ("PCI: Protect pci_error_handlers->reset_notify() usage with device_lock()") added protection around pci_dev_restore() function so a device-specific remove callback does not cause a race condition with hotplug. pci_dev_lock() usage has been forgotten in two places. Add locks for pci_slot_restore() and moving pci_dev_restore() inside the locks for pci_try_reset_function(). Signed-off-by: Sinan Kaya Signed-off-by: Bjorn Helgaas Reviewed-by: Christoph Hellwig --- diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 4db740e4f50a..660c848aa14a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4517,9 +4517,9 @@ int pci_try_reset_function(struct pci_dev *dev) pci_dev_save_and_disable(dev); rc = __pci_reset_function_locked(dev); + pci_dev_restore(dev); pci_dev_unlock(dev); - pci_dev_restore(dev); return rc; } EXPORT_SYMBOL_GPL(pci_try_reset_function); @@ -4727,7 +4727,9 @@ static void pci_slot_restore(struct pci_slot *slot) list_for_each_entry(dev, &slot->bus->devices, bus_list) { if (!dev->slot || dev->slot != slot) continue; + pci_dev_lock(dev); pci_dev_restore(dev); + pci_dev_unlock(dev); if (dev->subordinate) pci_bus_restore(dev->subordinate); }