From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Malcolm Priestley <tvboxspy@gmail.com>
Subject: Re: [PATVH] media, dvb, IX2505V: Remember to free allocated memory in failure path (ix2505v_attach()).
Date: Fri, 31 Dec 2010 08:30:04 -0200 [thread overview]
Message-ID: <4D1DB0AC.9090008@infradead.org> (raw)
In-Reply-To: <alpine.LNX.2.00.1012310008070.32595@swampdragon.chaosbits.net>
Em 30-12-2010 21:11, Jesper Juhl escreveu:
> Hi,
>
> We may leak the storage allocated to 'state' in
> drivers/media/dvb/frontends/ix2505v.c::ix2505v_attach() on error.
> This patch makes sure we free the allocated memory in the failure case.
>
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> ix2505v.c | 1 +
> 1 file changed, 1 insertion(+)
>
> Compile tested only.
>
> diff --git a/drivers/media/dvb/frontends/ix2505v.c b/drivers/media/dvb/frontends/ix2505v.c
> index 55f2eba..fcb173d 100644
> --- a/drivers/media/dvb/frontends/ix2505v.c
> +++ b/drivers/media/dvb/frontends/ix2505v.c
> @@ -293,6 +293,7 @@ struct dvb_frontend *ix2505v_attach(struct dvb_frontend *fe,
> ret = ix2505v_read_status_reg(state);
>
> if (ret & 0x80) {
> + kfree(state);
Instead of doing the free here, please move it to happen at the error: logic.
Currently, there's just one error condition, but having part of the release/kfree
logic here and there is not a good idea.
> deb_i2c("%s: No IX2505V found\n", __func__);
> goto error;
> }
>
>
>
next prev parent reply other threads:[~2010-12-31 10:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-30 23:11 [PATVH] media, dvb, IX2505V: Remember to free allocated memory in failure path (ix2505v_attach()) Jesper Juhl
2010-12-31 1:19 ` Malcolm Priestley
2010-12-31 14:51 ` Jesper Juhl
2010-12-31 18:33 ` Malcolm Priestley
2011-01-02 18:49 ` Jesper Juhl
2011-01-02 19:14 ` Jesper Juhl
2010-12-31 10:30 ` Mauro Carvalho Chehab [this message]
2010-12-31 12:21 ` Malcolm Priestley
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=4D1DB0AC.9090008@infradead.org \
--to=mchehab@infradead.org \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=tvboxspy@gmail.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.