From: Jesper Juhl <jesper.juhl@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Andy Grover <andrew.grover@intel.com>,
Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>,
Len Brown <len.brown@intel.com>,
linux-acpi@vger.kernel.org, Jesper Juhl <jesper.juhl@gmail.com>
Subject: [PATCH] mem-leak fix for acpi_thermal_write_trip_points()
Date: Sun, 14 May 2006 02:28:58 +0200 [thread overview]
Message-ID: <200605140228.58460.jesper.juhl@gmail.com> (raw)
There's a memory leak in
drivers/acpi/thermal.c::acpi_thermal_write_trip_points()
found by the Coverity checker as bug #1243
The problem is simply that if the allocation of 'active' fails, then we'll
return from the function without freeing the memory previously allocated
to 'limit_string'.
One fix would have been the insertion of kfree(limit_string); just before
the return_VALUE(-ENOMEM); call, but I chose a different fix.
Except for this one return the function only has a single exit point at
the end: label, and there it does proper cleanup of everything. So even
though setting the return value (the 'count' variable) and jumping there
results in a pointless kfree(NULL) call (since 'active' will be NULL), I
thought this was a small price to pay for the bennefit of having just a
single exit path for the function.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
drivers/acpi/thermal.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
--- linux-2.6.17-rc4-git2-orig/drivers/acpi/thermal.c 2006-03-20 06:53:29.000000000 +0100
+++ linux-2.6.17-rc4-git2/drivers/acpi/thermal.c 2006-05-14 02:18:30.000000000 +0200
@@ -942,8 +942,10 @@ acpi_thermal_write_trip_points(struct fi
memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN);
active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
- if (!active)
- return_VALUE(-ENOMEM);
+ if (!active) {
+ count = -ENOMEM;
+ goto end;
+ }
if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n"));
reply other threads:[~2006-05-14 0:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200605140228.58460.jesper.juhl@gmail.com \
--to=jesper.juhl@gmail.com \
--cc=andrew.grover@intel.com \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.s.diefenbaugh@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.