From: Jiang Liu Date: Mon, 21 Jan 2013 21:20:45 +0000 (-0800) Subject: PCI: Fix reference count leak in pci_dev_present() X-Git-Tag: firefly_0821_release~3680^2~1035^2^2~11 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d5af7d987a494a1b85e176b4c33dc115cb111662;p=firefly-linux-kernel-4.4.55.git PCI: Fix reference count leak in pci_dev_present() 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 Signed-off-by: Yinghai Lu Signed-off-by: Bjorn Helgaas Acked-by: Rafael J. Wysocki --- diff --git a/drivers/pci/search.c b/drivers/pci/search.c index bf969ba58e59..d0627fa9f368 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);