From: Andre Bartke <andre.bartke@googlemail.com>
To: mchehab@redhat.com
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Andre Bartke <andre.bartke@gmail.com>
Subject: [PATCH] staging: altera-stapl: Fix memory leak of altera_init()
Date: Mon, 30 May 2011 22:45:04 +0200 [thread overview]
Message-ID: <1306788304-21794-1-git-send-email-andre.bartke@gmail.com> (raw)
In case kzalloc() fails the second or third time
we should free the previous allocated resources.
Signed-off-by: Andre Bartke <andre.bartke@gmail.com>
---
drivers/staging/altera-stapl/altera.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/altera-stapl/altera.c b/drivers/staging/altera-stapl/altera.c
index 05aad35..56ba557 100644
--- a/drivers/staging/altera-stapl/altera.c
+++ b/drivers/staging/altera-stapl/altera.c
@@ -2435,11 +2435,16 @@ int altera_init(struct altera_config *config, const struct firmware *fw)
if (!key)
return -ENOMEM;
value = kzalloc(257 * sizeof(char), GFP_KERNEL);
- if (!value)
+ if (!value) {
+ kfree(key);
return -ENOMEM;
+ }
astate = kzalloc(sizeof(struct altera_state), GFP_KERNEL);
- if (!astate)
+ if (!astate) {
+ kfree(key);
+ kfree(value);
return -ENOMEM;
+ }
astate->config = config;
if (!astate->config->jtag_io) {
--
1.7.5.2
next reply other threads:[~2011-05-30 20:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-30 20:45 Andre Bartke [this message]
2011-05-30 23:11 ` [PATCH] staging: altera-stapl: Fix memory leak of altera_init() Peter Hüwe
2011-05-30 23:13 ` Jesper Juhl
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=1306788304-21794-1-git-send-email-andre.bartke@gmail.com \
--to=andre.bartke@googlemail.com \
--cc=andre.bartke@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@redhat.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