From: Jesper Juhl <jesper.juhl@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: "Jochen Schäuble" <psionic@psionic.de>,
"Jörn Engel" <joern@wohnheim.fh-wedel.de>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Jesper Juhl" <jesper.juhl@gmail.com>
Subject: [PATCH] mtd: fix memory leaks in phram_setup
Date: Sun, 14 May 2006 01:07:18 +0200 [thread overview]
Message-ID: <200605140107.18293.jesper.juhl@gmail.com> (raw)
There are two code paths in drivers/mtd/devices/phram.c::phram_setup() that
will leak memory.
Memory is allocated to the variable 'name' with kmalloc() by the
parse_name() function, but if we leave by way of the parse_err() macro,
then that memory is never kfree()'d, nor is it ever used with
register_device() so it won't be freed later either - leak.
Found by the Coverity checker as #593 - simple fix below.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
drivers/mtd/devices/phram.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
--- linux-2.6.17-rc4-git2-orig/drivers/mtd/devices/phram.c 2006-03-20 06:53:29.000000000 +0100
+++ linux-2.6.17-rc4-git2/drivers/mtd/devices/phram.c 2006-05-14 01:05:27.000000000 +0200
@@ -266,12 +266,16 @@ static int phram_setup(const char *val,
return 0;
ret = parse_num32(&start, token[1]);
- if (ret)
+ if (ret) {
+ kfree(name);
parse_err("illegal start address\n");
+ }
ret = parse_num32(&len, token[2]);
- if (ret)
+ if (ret) {
+ kfree(name);
parse_err("illegal device length\n");
+ }
register_device(name, start, len);
next reply other threads:[~2006-05-13 23:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-13 23:07 Jesper Juhl [this message]
2006-05-13 23:18 ` David Woodhouse
2006-05-13 23:34 ` Jesper Juhl
2006-05-13 23:40 ` David Woodhouse
2006-05-14 6:37 ` Jörn Engel
2006-05-14 11:03 ` David Woodhouse
2006-05-14 13:21 ` Jörn Engel
2006-05-14 16:37 ` Ingo Oeser
2006-05-14 20:07 ` Jörn Engel
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=200605140107.18293.jesper.juhl@gmail.com \
--to=jesper.juhl@gmail.com \
--cc=joern@wohnheim.fh-wedel.de \
--cc=linux-kernel@vger.kernel.org \
--cc=psionic@psionic.de \
--cc=tglx@linutronix.de \
/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®