From: Yinghai Lu <yinghai@kernel.org>
To: Jesse Barnes <jbarnes@virtuousgeek.org>, x86 <x86@kernel.org>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Yinghai Lu <yinghai@kernel.org>,
stable@kernel.org, Len Brown <lenb@kernel.org>,
Adam Belay <abelay@mit.edu>, Bjorn Helgaas <bhelgaas@google.com>,
linux-acpi@vger.kernel.org
Subject: [PATCH 08/23] PNPACPI: Fix device ref leaking in acpi_pnp_match
Date: Mon, 5 Mar 2012 23:13:45 -0800 [thread overview]
Message-ID: <1331018040-30725-9-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1331018040-30725-1-git-send-email-yinghai@kernel.org>
During testing pci root bus removal, found some root bus bridge is not freed.
If booting with pnpacpi=off, those hostbridge could be freed without problem.
It turns out that some devices reference are not released during acpi_pnp_match.
that match should not hold one device ref during every calling.
Add put_device calling before returning.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: stable@kernel.org
Cc: Len Brown <lenb@kernel.org>
Cc: Adam Belay <abelay@mit.edu>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-acpi@vger.kernel.org
---
drivers/pnp/pnpacpi/core.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index b00c176..d21e8f5 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -321,9 +321,14 @@ static int __init acpi_pnp_match(struct device *dev, void *_pnp)
{
struct acpi_device *acpi = to_acpi_device(dev);
struct pnp_dev *pnp = _pnp;
+ struct device *physical_device;
+
+ physical_device = acpi_get_physical_device(acpi->handle);
+ if (physical_device)
+ put_device(physical_device);
/* true means it matched */
- return !acpi_get_physical_device(acpi->handle)
+ return !physical_device
&& compare_pnp_id(pnp->id, acpi_device_hid(acpi));
}
--
1.7.7
next parent reply other threads:[~2012-03-06 7:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1331018040-30725-1-git-send-email-yinghai@kernel.org>
2012-03-06 7:13 ` Yinghai Lu [this message]
2012-03-07 3:53 ` [PATCH 08/23] PNPACPI: Fix device ref leaking in acpi_pnp_match Bjorn Helgaas
2012-03-06 7:13 ` [PATCH 17/23] PCI, ACPI: make acpi_pci_root_remove remove pci root bus too Yinghai Lu
2012-03-06 7:13 ` [PATCH 18/23] PCI, ACPI: add acpi_pci_root_rescan() Yinghai Lu
2012-03-07 4:40 ` Bjorn Helgaas
[not found] ` <1331018040-30725-17-git-send-email-yinghai@kernel.org>
[not found] ` <CAErSpo59kzBL1ApWuWWcymd9UR3m3vB3zkUoJezn66As+-97dQ@mail.gmail.com>
[not found] ` <CAE9FiQVTng2Bi4z9YY9CustC7KkTr-6+qFaaqu8F4dd0WAKGig@mail.gmail.com>
2012-03-08 4:45 ` [PATCH 16/23] PCI: add pci bus removal through /sys/.../pci_bus/.../remove Bjorn Helgaas
2012-03-08 15:45 ` Greg Kroah-Hartman
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=1331018040-30725-9-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=abelay@mit.edu \
--cc=bhelgaas@google.com \
--cc=jbarnes@virtuousgeek.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=stable@kernel.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