From: Keith Busch Date: Thu, 30 Mar 2017 03:49:17 +0000 (-0500) Subject: PCI: Short-circuit pci_device_is_present() for disconnected devices X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=fe2bd75b2290bf6acd4b91312697e445668dd773;p=linux.git PCI: Short-circuit pci_device_is_present() for disconnected devices 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 Signed-off-by: Keith Busch Signed-off-by: Bjorn Helgaas Reviewed-by: Christoph Hellwig Reviewed-by: Wei Zhang --- diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7904d02ffdb97..8ab0a0d3cddb2 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -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);