linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: stefan.wahren@i2se.com (Stefan Wahren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] staging: bcm2835: Fix a memory leak in error handling path
Date: Fri, 24 Feb 2017 13:37:30 +0100	[thread overview]
Message-ID: <6585ca42-71f4-1517-c6fc-b9ed2f23c687@i2se.com> (raw)
In-Reply-To: <20170219103412.10092-1-christophe.jaillet@wanadoo.fr>

Hi Christophe,

Am 19.02.2017 um 11:34 schrieb Christophe JAILLET:
> If 'kzalloc()' fails, we should release resources allocated so far, just as
> done in all other cases in this function.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Not sure that the error handling path is correct.
> Is 'gdev[0]' freed? Should it be?

sorry, didn't checked your patch yet. Currently there are 3 bcm2835 
drivers in staging (vchiq, camera, audio). So please resend with a more 
distinct subject.

Thanks
Stefan

> ---
>   drivers/staging/media/platform/bcm2835/bcm2835-camera.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
> index ca15a698e018..9651b9bc3439 100644
> --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
> +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
> @@ -1914,8 +1914,10 @@ static int __init bm2835_mmal_init(void)
>   
>   	for (camera = 0; camera < num_cameras; camera++) {
>   		dev = kzalloc(sizeof(struct bm2835_mmal_dev), GFP_KERNEL);
> -		if (!dev)
> -			return -ENOMEM;
> +		if (!dev) {
> +			ret = -ENOMEM;
> +			goto free_dev;
> +		}
>   
>   		dev->camera_num = camera;
>   		dev->max_width = resolutions[camera][0];

  reply	other threads:[~2017-02-24 12:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-19 10:34 [PATCH] staging: bcm2835: Fix a memory leak in error handling path Christophe JAILLET
2017-02-24 12:37 ` Stefan Wahren [this message]
2017-02-24 19:57   ` Dan Carpenter
2017-02-24 21:38     ` Stefan Wahren
2017-02-25  4:11       ` Dan Carpenter

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=6585ca42-71f4-1517-c6fc-b9ed2f23c687@i2se.com \
    --to=stefan.wahren@i2se.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).