]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
PCI: Short-circuit pci_device_is_present() for disconnected devices
authorKeith Busch <keith.busch@intel.com>
Thu, 30 Mar 2017 03:49:17 +0000 (22:49 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 30 Mar 2017 03:55:16 +0000 (22:55 -0500)
If the PCI device is disconnected, return false immediately from
pci_device_is_present().  pci_device_is_present() uses the bus accessors,
so the early return in the device accessors doesn't help here.

Tested-by: Krishna Dhulipala <krishnad@fb.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Wei Zhang <wzhang@fb.com>
drivers/pci/pci.c

index 7904d02ffdb97e5f23d915e9c83edbf599ddf58b..8ab0a0d3cddb209adff1c6ec4e899efc12f1244c 100644 (file)
@@ -4932,6 +4932,8 @@ bool pci_device_is_present(struct pci_dev *pdev)
 {
        u32 v;
 
+       if (pci_dev_is_disconnected(pdev))
+               return false;
        return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);
 }
 EXPORT_SYMBOL_GPL(pci_device_is_present);