aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/xen-pcifront.c
diff options
context:
space:
mode:
authorJiang Liu <liuj97@gmail.com>2012-08-28 11:43:58 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-09-12 16:15:16 -0400
commit2ccc246d9c6eaa6596818ff917721a444acd0b61 (patch)
tree6297910761193df4c52fc61a7e336c54e4aa3d12 /drivers/pci/xen-pcifront.c
parent433efd2247b0cbf5e7e86275e1f21281d3b99047 (diff)
xen-pcifront: Use hotplug-safe pci_get_domain_bus_and_slot()
Following code has a race window between pci_find_bus() and pci_get_slot() if PCI hotplug operation happens between them which removes the pci_bus. So use PCI hotplug safe interface pci_get_domain_bus_and_slot() instead, which also reduces code complexity. struct pci_bus *pci_bus = pci_find_bus(domain, busno); struct pci_dev *pci_dev = pci_get_slot(pci_bus, devfn); Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/pci/xen-pcifront.c')
-rw-r--r--drivers/pci/xen-pcifront.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index d6cc62cb4cf7..def8d0b5620c 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -982,7 +982,6 @@ static int pcifront_detach_devices(struct pcifront_device *pdev)
982 int err = 0; 982 int err = 0;
983 int i, num_devs; 983 int i, num_devs;
984 unsigned int domain, bus, slot, func; 984 unsigned int domain, bus, slot, func;
985 struct pci_bus *pci_bus;
986 struct pci_dev *pci_dev; 985 struct pci_dev *pci_dev;
987 char str[64]; 986 char str[64];
988 987
@@ -1032,13 +1031,8 @@ static int pcifront_detach_devices(struct pcifront_device *pdev)
1032 goto out; 1031 goto out;
1033 } 1032 }
1034 1033
1035 pci_bus = pci_find_bus(domain, bus); 1034 pci_dev = pci_get_domain_bus_and_slot(domain, bus,
1036 if (!pci_bus) { 1035 PCI_DEVFN(slot, func));
1037 dev_dbg(&pdev->xdev->dev, "Cannot get bus %04x:%02x\n",
1038 domain, bus);
1039 continue;
1040 }
1041 pci_dev = pci_get_slot(pci_bus, PCI_DEVFN(slot, func));
1042 if (!pci_dev) { 1036 if (!pci_dev) {
1043 dev_dbg(&pdev->xdev->dev, 1037 dev_dbg(&pdev->xdev->dev,
1044 "Cannot get PCI device %04x:%02x:%02x.%d\n", 1038 "Cannot get PCI device %04x:%02x:%02x.%d\n",