From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>,
Taku Izumi <izumi.taku@jp.fujitsu.com>,
Jiang Liu <jiang.liu@huawei.com>, x86 <x86@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-acpi@vger.kernel.org
Subject: [PATCH part4 01/11] PCI: Fix a device reference count leakage issue in pci_dev_present()
Date: Sun, 2 Sep 2012 14:54:11 -0700 [thread overview]
Message-ID: <1346622861-30865-2-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1346622861-30865-1-git-send-email-yinghai@kernel.org>
From: Jiang Liu <jiang.liu@huawei.com>
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>
---
drivers/pci/search.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d84cdcf..cd11bd8 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -338,13 +338,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);
--
1.7.7
next prev parent reply other threads:[~2012-09-02 21:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-02 21:54 [PATCH part4 00/11] PCI, ACPI: pci root bus hotplug support - part4 Yinghai Lu
2012-09-02 21:54 ` Yinghai Lu [this message]
2012-09-02 21:54 ` [PATCH part4 02/11] PCI: Correctly clean up pci root buses in function pci_remove_bus() Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 03/11] PCI: Add pci_stop_and_remove_bus() Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 04/11] PCI: Fix an access-after-free issue in function pci_stop_and_remove_bus() Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 05/11] PCI, acpiphp: Separate out hot-add support of pci host bridge Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 06/11] PCI, ACPI: Make acpi_pci_root_remove remove pci root bus too Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 07/11] PCI, ACPI: Add pci_root_hp hot removal notification support Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 08/11] PCI, ACPI: Add alloc_acpi_hp_work() Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 09/11] PCI, acpiphp: Use acpi_hp_work Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 10/11] PCI, pci_root_hp: " Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 11/11] PCI, ACPI: Make kacpi_hotplug_wq static Yinghai Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1346622861-30865-2-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=izumi.taku@jp.fujitsu.com \
--cc=jiang.liu@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).