PCI: Fix reference count leak in pci_dev_present()
authorJiang Liu <jiang.liu@huawei.com>
Mon, 21 Jan 2013 21:20:45 +0000 (13:20 -0800)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 25 Jan 2013 20:49:27 +0000 (13:49 -0700)
Function pci_get_dev_by_id() takes a reference on the pci_dev returned, so
pci_dev_present() should release the corresponding reference.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/pci/search.c

index bf969ba58e59d10aa770909005bee01ac76dd060..d0627fa9f36827fdd864e462d519fd2279ef7d56 100644 (file)
@@ -319,13 +319,13 @@ int pci_dev_present(const struct pci_device_id *ids)
        WARN_ON(in_interrupt());
        while (ids->vendor || ids->subvendor || ids->class_mask) {
                found = pci_get_dev_by_id(ids, NULL);
-               if (found)
-                       goto exit;
+               if (found) {
+                       pci_dev_put(found);
+                       return 1;
+               }
                ids++;
        }
-exit:
-       if (found)
-               return 1;
+
        return 0;
 }
 EXPORT_SYMBOL(pci_dev_present);