aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@huawei.com>2012-04-06 23:31:36 +0800
committerYinghai Lu <yinghai@kernel.org>2012-09-17 22:16:10 -0700
commit7d5edebd935c975ae7401ae25eb72b7f134788b9 (patch)
tree366e9e86d22941e0ee16988888a08fcbcd779bb0
parent282e2db3b58d56b5236ee755e1527574df0d298e (diff)
downloadlinux-yinghai-7d5edebd935c975ae7401ae25eb72b7f134788b9.tar.gz
PCI: Fix a device reference count leakage issue in pci_dev_present()
Function pci_get_dev_by_id() will hold a reference count on the pci device returned, so pci_dev_present() should release the corresponding reference count to avoid memory leakage. Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
-rw-r--r--drivers/pci/search.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index bf969ba58e59d..d0627fa9f3682 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -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);