From: Jesper Juhl <jesper.juhl@gmail.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Thomas Hood <dthood@mail.com>,
David Hinds <dahinds@users.sourceforge.net>,
Jesper Juhl <jesper.juhl@gmail.com>
Subject: [PATCH][pnp] Avoid a small unlikely memory leak in proc_read_escd()
Date: Fri, 20 Jul 2007 23:41:06 +0200 [thread overview]
Message-ID: <200707202341.06710.jesper.juhl@gmail.com> (raw)
Hi,
There's a small and unlikely memory leak in
drivers/pnp/pnpbios/proc.c::proc_read_escd(). It's inside a sanity
check, so it probably won't trigger often (if at all), however it
*is* a potential leak and it's easy to avoid, so let's just fix it :)
While I was in there I also broke a oneline 'if' statement into two
lines - seemed too trivial a changee to warrent a seperate patch.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
drivers/pnp/pnpbios/proc.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index 8027073..f77b8c4 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -88,7 +88,8 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
}
tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL);
- if (!tmpbuf) return -ENOMEM;
+ if (!tmpbuf)
+ return -ENOMEM;
if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) {
kfree(tmpbuf);
@@ -100,6 +101,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
/* sanity check */
if (escd_size > MAX_SANE_ESCD_SIZE) {
printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by BIOS read_escd call is too great\n");
+ kfree(tmpbuf);
return -EFBIG;
}
reply other threads:[~2007-07-20 21:42 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=200707202341.06710.jesper.juhl@gmail.com \
--to=jesper.juhl@gmail.com \
--cc=dahinds@users.sourceforge.net \
--cc=dthood@mail.com \
--cc=linux-kernel@vger.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
Powered by JetHome