From: Jiang Liu <jiang.liu@linux.intel.com>
To: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Lv Zheng <lv.zheng@intel.com>, Len Brown <lenb@kernel.org>,
Leonidas Da Silva Barbosa <leosilva@linux.vnet.ibm.com>,
Ashley Lai <ashley@ashleylai.com>,
Peter Huewe <peterhuewe@gmx.de>, Rajiv Andrade <mail@srajiv.net>,
Marcel Selhorst <tpmdd@selhorst.net>,
Sirrix AG <tpmdd@sirrix.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>,
Tony Luck <tony.luck@intel.com>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
tpmdd-devel@lists.sourceforge.net
Subject: [Patch v2 06/13] ACPI, TPM: fix memory leak when walking ACPI namespace
Date: Thu, 19 Dec 2013 20:38:15 +0800 [thread overview]
Message-ID: <1387456702-4709-7-git-send-email-jiang.liu@linux.intel.com> (raw)
In-Reply-To: <1387456702-4709-1-git-send-email-jiang.liu@linux.intel.com>
In function ppi_callback(), memory allocated by acpi_get_name() will get
leaked when current device isn't the desired TPM device, so fix the
memory leak.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Cc: <stable@vger.kernel.org> # 3.6
---
drivers/char/tpm/tpm_ppi.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
index 8e562dc..e1f3337 100644
--- a/drivers/char/tpm/tpm_ppi.c
+++ b/drivers/char/tpm/tpm_ppi.c
@@ -27,15 +27,18 @@ static char *tpm_device_name = "TPM";
static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context,
void **return_value)
{
- acpi_status status;
+ acpi_status status = AE_OK;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
- status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
- if (strstr(buffer.pointer, context) != NULL) {
- *return_value = handle;
+
+ if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer))) {
+ if (strstr(buffer.pointer, context) != NULL) {
+ *return_value = handle;
+ status = AE_CTRL_TERMINATE;
+ }
kfree(buffer.pointer);
- return AE_CTRL_TERMINATE;
}
- return AE_OK;
+
+ return status;
}
static inline void ppi_assign_params(union acpi_object params[4],
--
1.7.10.4
next prev parent reply other threads:[~2013-12-19 12:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 12:38 [Patch v2 00/13] Introduce ACPI _DSM helper functions to simplify code Jiang Liu
2013-12-19 12:38 ` [Patch v2 01/13] ACPI: introduce helper interfaces to support ACPI _DSM method Jiang Liu
2013-12-19 12:38 ` [Patch v2 03/13] PCI, pci-label: release allocated ACPI object on error recovery path Jiang Liu
2013-12-19 18:22 ` Bjorn Helgaas
2013-12-20 2:01 ` Rafael J. Wysocki
2013-12-19 12:38 ` [Patch v2 04/13] ACPI, PCI: replace open-coded _DSM specific code with helper functions Jiang Liu
2013-12-19 12:38 ` [Patch v2 05/13] PCI, pci-label: treat PCI label with index 0 as valid label Jiang Liu
2013-12-19 12:38 ` Jiang Liu [this message]
2013-12-19 12:38 ` [Patch v2 07/13] ACPI, TPM: matching node name instead of full path when searching for TPM device Jiang Liu
2013-12-19 12:38 ` [Patch v2 08/13] ACPI, TPM: replace open-coded _DSM specific code with helper functions Jiang Liu
2013-12-19 12:38 ` [Patch v2 09/13] ACPI, TPM: detecting PPI features by checking availability of _DSM functions Jiang Liu
2013-12-19 12:38 ` [Patch v2 10/13] ACPI, i2c-hid: replace open-coded _DSM specific code with helper functions Jiang Liu
2013-12-19 12:38 ` [Patch v2 11/13] ACPI, i915: " Jiang Liu
2013-12-19 12:38 ` [Patch v2 12/13] nouveau: fix memory leak in ACPI _DSM related code Jiang Liu
2013-12-19 12:38 ` [Patch v2 13/13] ACPI, nouveau: replace open-coded _DSM specific code with helper functions Jiang Liu
2014-01-05 21:58 ` [Patch v2 00/13] Introduce ACPI _DSM helper functions to simplify code Rafael J. Wysocki
2014-01-06 6:18 ` Jiang Liu
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=1387456702-4709-7-git-send-email-jiang.liu@linux.intel.com \
--to=jiang.liu@linux.intel.com \
--cc=ashley@ashleylai.com \
--cc=bhelgaas@google.com \
--cc=lenb@kernel.org \
--cc=leosilva@linux.vnet.ibm.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lv.zheng@intel.com \
--cc=mail@srajiv.net \
--cc=peterhuewe@gmx.de \
--cc=rafael.j.wysocki@intel.com \
--cc=tony.luck@intel.com \
--cc=tpmdd-devel@lists.sourceforge.net \
--cc=tpmdd@selhorst.net \
--cc=tpmdd@sirrix.com \
/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).