]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
PCI: Use hotplug-safe pci_get_domain_bus_and_slot()
authorJiang Liu <liuj97@gmail.com>
Tue, 28 Aug 2012 15:43:57 +0000 (23:43 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 12 Sep 2012 20:14:30 +0000 (14:14 -0600)
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);

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/iov.c

index 74bbaf82638d9062817c4c7a1b872f506423f1ab..c7d2969699be1b567767624b1026b6eda3c481e7 100644 (file)
@@ -152,15 +152,11 @@ failed1:
 static void virtfn_remove(struct pci_dev *dev, int id, int reset)
 {
        char buf[VIRTFN_ID_LEN];
-       struct pci_bus *bus;
        struct pci_dev *virtfn;
        struct pci_sriov *iov = dev->sriov;
 
-       bus = pci_find_bus(pci_domain_nr(dev->bus), virtfn_bus(dev, id));
-       if (!bus)
-               return;
-
-       virtfn = pci_get_slot(bus, virtfn_devfn(dev, id));
+       virtfn = pci_get_domain_bus_and_slot(pci_domain_nr(dev->bus),
+                       virtfn_bus(dev, id), virtfn_devfn(dev, id));
        if (!virtfn)
                return;