All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] [media] em28xx-input: NULL dereference on error
Date: Thu, 25 Sep 2014 14:08:31 +0000	[thread overview]
Message-ID: <542421DF.9060000@googlemail.com> (raw)
In-Reply-To: <20140925113941.GB3708@mwanda>

Hi Dan,

Am 25.09.2014 um 13:39 schrieb Dan Carpenter:
> We call "kfree(ir->i2c_client);" in the error handling and that doesn't
> work if "ir" is NULL.
>
> Fixes: 78e719a5f30b ('[media] em28xx-input: i2c IR decoders: improve i2c_client handling')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
> index 581f6da..23f8f6a 100644
> --- a/drivers/media/usb/em28xx/em28xx-input.c
> +++ b/drivers/media/usb/em28xx/em28xx-input.c
> @@ -712,8 +712,10 @@ static int em28xx_ir_init(struct em28xx *dev)
>  	em28xx_info("Registering input extension\n");
>  
>  	ir = kzalloc(sizeof(*ir), GFP_KERNEL);
> +	if (!ir)
> +		return -ENOMEM;
>  	rc = rc_allocate_device();
> -	if (!ir || !rc)
> +	if (!rc)
>  		goto error;
>  
>  	/* record handles to ourself */
I would prefer to fix it where the actual problem is located.
Can you send an updated version that changes the code to do

...
error:
if (ir)
  kfree(ir->i2c_client);
...

This makes the code less prone to future error handling changes.

Thanks !

Regards,
Frank


WARNING: multiple messages have this Message-ID (diff)
From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] [media] em28xx-input: NULL dereference on error
Date: Thu, 25 Sep 2014 16:08:31 +0200	[thread overview]
Message-ID: <542421DF.9060000@googlemail.com> (raw)
In-Reply-To: <20140925113941.GB3708@mwanda>

Hi Dan,

Am 25.09.2014 um 13:39 schrieb Dan Carpenter:
> We call "kfree(ir->i2c_client);" in the error handling and that doesn't
> work if "ir" is NULL.
>
> Fixes: 78e719a5f30b ('[media] em28xx-input: i2c IR decoders: improve i2c_client handling')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
> index 581f6da..23f8f6a 100644
> --- a/drivers/media/usb/em28xx/em28xx-input.c
> +++ b/drivers/media/usb/em28xx/em28xx-input.c
> @@ -712,8 +712,10 @@ static int em28xx_ir_init(struct em28xx *dev)
>  	em28xx_info("Registering input extension\n");
>  
>  	ir = kzalloc(sizeof(*ir), GFP_KERNEL);
> +	if (!ir)
> +		return -ENOMEM;
>  	rc = rc_allocate_device();
> -	if (!ir || !rc)
> +	if (!rc)
>  		goto error;
>  
>  	/* record handles to ourself */
I would prefer to fix it where the actual problem is located.
Can you send an updated version that changes the code to do

...
error:
if (ir)
  kfree(ir->i2c_client);
...

This makes the code less prone to future error handling changes.

Thanks !

Regards,
Frank


  reply	other threads:[~2014-09-25 14:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-25 11:39 [patch] [media] em28xx-input: NULL dereference on error Dan Carpenter
2014-09-25 11:39 ` Dan Carpenter
2014-09-25 14:08 ` Frank Schäfer [this message]
2014-09-25 14:08   ` Frank Schäfer
2014-09-25 14:49   ` Dan Carpenter
2014-09-25 14:49     ` Dan Carpenter
2014-09-25 17:50     ` Frank Schäfer
2014-09-25 17:50       ` Frank Schäfer
2014-09-25 15:37   ` Julia Lawall
2014-09-25 15:37     ` Julia Lawall
2014-09-25 16:28     ` Mauro Carvalho Chehab
2014-09-25 16:28       ` Mauro Carvalho Chehab

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=542421DF.9060000@googlemail.com \
    --to=fschaefer.oss@googlemail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.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.