From: Hanjun Guo <hanjun.guo@linaro.org>
To: Lv Zheng <lv.zheng@intel.com>, Robert Moore <robert.moore@intel.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
linux-acpi@vger.kernel.org, devel@acpica.org, patches@linaro.org,
linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org,
Hanjun Guo <hanjun.guo@linaro.org>,
Yijing Wang <wangyijing@huawei.com>
Subject: [PATCH 2/2] ACPI / ACPICA: Fix potential memory leak in acpi_evaluate_object()
Date: Sat, 25 Jan 2014 00:20:07 +0800 [thread overview]
Message-ID: <1390580407-14525-2-git-send-email-hanjun.guo@linaro.org> (raw)
In-Reply-To: <1390580407-14525-1-git-send-email-hanjun.guo@linaro.org>
There is a potential memory leak when acpi_ut_copy_iobject_to_eobject()
failed, because return_buffer was allocated in acpi_ut_initialize_buffer()
when buffer type is ACPI_ALLOCATE_BUFFER or ACPI_ALLOCATE_LOCAL_BUFFER,
and will not be freed outside when the return value is not AE_OK for
acpi_evaluate_object(), fix it.
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
drivers/acpi/acpica/nsxfeval.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index a1b0b88..8ad792b 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -424,6 +424,11 @@ acpi_evaluate_object(acpi_handle handle,
status = acpi_ut_copy_iobject_to_eobject(
info->return_object, return_buffer);
+ if (ACPI_FAILURE(status) &&
+ (buffer_space_needed == ACPI_ALLOCATE_BUFFER ||
+ buffer_space_needed == ACPI_ALLOCATE_LOCAL_BUFFER)) {
+ ACPI_FREE(return_buffer);
+ }
}
}
--
1.7.9.5
next prev parent reply other threads:[~2014-01-24 16:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-24 16:20 [PATCH 1/2] ACPI / ACPICA: refactor acpi_evaluate_object() to reduce nesting if Hanjun Guo
2014-01-24 16:20 ` Hanjun Guo [this message]
2014-01-24 16:29 ` Moore, Robert
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=1390580407-14525-2-git-send-email-hanjun.guo@linaro.org \
--to=hanjun.guo@linaro.org \
--cc=devel@acpica.org \
--cc=linaro-acpi@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lv.zheng@intel.com \
--cc=patches@linaro.org \
--cc=rjw@rjwysocki.net \
--cc=robert.moore@intel.com \
--cc=wangyijing@huawei.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
all inboxes | Powered by JetHome®