All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] s2255drv: fix memory leak s2255_probe()
@ 2014-04-15  4:49 Daeseok Youn
  2014-04-15  9:33 ` Sakari Ailus
  0 siblings, 1 reply; 8+ messages in thread
From: Daeseok Youn @ 2014-04-15  4:49 UTC (permalink / raw)
  To: m.chehab; +Cc: linux-dev, hans.verkuil, sakari.ailus, linux-media, linux-kernel


smatch says:
 drivers/media/usb/s2255/s2255drv.c:2246 s2255_probe() warn:
possible memory leak of 'dev'

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
---
 drivers/media/usb/s2255/s2255drv.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 1d4ba2b..8aca3ef 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface,
 	dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
 	if (dev->cmdbuf == NULL) {
 		s2255_dev_err(&interface->dev, "out of memory\n");
+		kfree(dev);
 		return -ENOMEM;
 	}
 
-- 
1.7.4.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] [media] s2255drv: fix memory leak s2255_probe()
  2014-04-15  4:49 [PATCH] [media] s2255drv: fix memory leak s2255_probe() Daeseok Youn
@ 2014-04-15  9:33 ` Sakari Ailus
  2014-04-15 10:54   ` DaeSeok Youn
  0 siblings, 1 reply; 8+ messages in thread
From: Sakari Ailus @ 2014-04-15  9:33 UTC (permalink / raw)
  To: Daeseok Youn; +Cc: m.chehab, linux-dev, hans.verkuil, linux-media, linux-kernel

Hi Daeseok,

On Tue, Apr 15, 2014 at 01:49:34PM +0900, Daeseok Youn wrote:
> 
> smatch says:
>  drivers/media/usb/s2255/s2255drv.c:2246 s2255_probe() warn:
> possible memory leak of 'dev'
> 
> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> ---
>  drivers/media/usb/s2255/s2255drv.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
> index 1d4ba2b..8aca3ef 100644
> --- a/drivers/media/usb/s2255/s2255drv.c
> +++ b/drivers/media/usb/s2255/s2255drv.c
> @@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface,
>  	dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
>  	if (dev->cmdbuf == NULL) {
>  		s2255_dev_err(&interface->dev, "out of memory\n");
> +		kfree(dev);
>  		return -ENOMEM;
>  	}
>  

The rest of the function already uses goto and labels for error handling. I
think it'd take adding one more. dev is correctly released in other error
cases.

What do you think?

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [media] s2255drv: fix memory leak s2255_probe()
  2014-04-15  9:33 ` Sakari Ailus
@ 2014-04-15 10:54   ` DaeSeok Youn
  2014-05-05  8:38     ` Sakari Ailus
  0 siblings, 1 reply; 8+ messages in thread
From: DaeSeok Youn @ 2014-04-15 10:54 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: m.chehab, linux-dev, hans.verkuil, linux-media, linux-kernel

Hi, Sakari

2014-04-15 18:33 GMT+09:00 Sakari Ailus <sakari.ailus@iki.fi>:
> Hi Daeseok,
>
> On Tue, Apr 15, 2014 at 01:49:34PM +0900, Daeseok Youn wrote:
>>
>> smatch says:
>>  drivers/media/usb/s2255/s2255drv.c:2246 s2255_probe() warn:
>> possible memory leak of 'dev'
>>
>> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
>> ---
>>  drivers/media/usb/s2255/s2255drv.c |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
>> index 1d4ba2b..8aca3ef 100644
>> --- a/drivers/media/usb/s2255/s2255drv.c
>> +++ b/drivers/media/usb/s2255/s2255drv.c
>> @@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface,
>>       dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
>>       if (dev->cmdbuf == NULL) {
>>               s2255_dev_err(&interface->dev, "out of memory\n");
>> +             kfree(dev);
>>               return -ENOMEM;
>>       }
>>
>
> The rest of the function already uses goto and labels for error handling. I
> think it'd take adding one more. dev is correctly released in other error
> cases.
I am not sure that adding a new label for error handling when
allocation for dev->cmdbuf is failed.
I think it is ok to me. :-) Because I think it is not good adding a
new label and use goto statement for this.

Thanks for review.

Regards,
Daeseok Youn.
>
> What do you think?
>
> --
> Kind regards,
>
> Sakari Ailus
> e-mail: sakari.ailus@iki.fi     XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [media] s2255drv: fix memory leak s2255_probe()
  2014-04-15 10:54   ` DaeSeok Youn
@ 2014-05-05  8:38     ` Sakari Ailus
  2014-05-07  4:38       ` DaeSeok Youn
  0 siblings, 1 reply; 8+ messages in thread
From: Sakari Ailus @ 2014-05-05  8:38 UTC (permalink / raw)
  To: DaeSeok Youn; +Cc: m.chehab, linux-dev, hans.verkuil, linux-media, linux-kernel

On Tue, Apr 15, 2014 at 07:54:43PM +0900, DaeSeok Youn wrote:
> Hi, Sakari
> 
> 2014-04-15 18:33 GMT+09:00 Sakari Ailus <sakari.ailus@iki.fi>:
> > Hi Daeseok,
> >
> > On Tue, Apr 15, 2014 at 01:49:34PM +0900, Daeseok Youn wrote:
> >>
> >> smatch says:
> >>  drivers/media/usb/s2255/s2255drv.c:2246 s2255_probe() warn:
> >> possible memory leak of 'dev'
> >>
> >> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> >> ---
> >>  drivers/media/usb/s2255/s2255drv.c |    1 +
> >>  1 files changed, 1 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
> >> index 1d4ba2b..8aca3ef 100644
> >> --- a/drivers/media/usb/s2255/s2255drv.c
> >> +++ b/drivers/media/usb/s2255/s2255drv.c
> >> @@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface,
> >>       dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
> >>       if (dev->cmdbuf == NULL) {
> >>               s2255_dev_err(&interface->dev, "out of memory\n");
> >> +             kfree(dev);
> >>               return -ENOMEM;
> >>       }
> >>
> >
> > The rest of the function already uses goto and labels for error handling. I
> > think it'd take adding one more. dev is correctly released in other error
> > cases.
> I am not sure that adding a new label for error handling when
> allocation for dev->cmdbuf is failed.
> I think it is ok to me. :-) Because I think it is not good adding a
> new label and use goto statement for this.

I can ack this if you use the same pattern for error handling that's already
there.

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [media] s2255drv: fix memory leak s2255_probe()
  2014-05-05  8:38     ` Sakari Ailus
@ 2014-05-07  4:38       ` DaeSeok Youn
  2014-05-08 11:21         ` Sakari Ailus
  0 siblings, 1 reply; 8+ messages in thread
From: DaeSeok Youn @ 2014-05-07  4:38 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: m.chehab, linux-dev, hans.verkuil, linux-media, linux-kernel

Hello,

2014-05-05 17:38 GMT+09:00 Sakari Ailus <sakari.ailus@iki.fi>:
> On Tue, Apr 15, 2014 at 07:54:43PM +0900, DaeSeok Youn wrote:
>> Hi, Sakari
>>
>> 2014-04-15 18:33 GMT+09:00 Sakari Ailus <sakari.ailus@iki.fi>:
>> > Hi Daeseok,
>> >
>> > On Tue, Apr 15, 2014 at 01:49:34PM +0900, Daeseok Youn wrote:
>> >>
>> >> smatch says:
>> >>  drivers/media/usb/s2255/s2255drv.c:2246 s2255_probe() warn:
>> >> possible memory leak of 'dev'
>> >>
>> >> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
>> >> ---
>> >>  drivers/media/usb/s2255/s2255drv.c |    1 +
>> >>  1 files changed, 1 insertions(+), 0 deletions(-)
>> >>
>> >> diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
>> >> index 1d4ba2b..8aca3ef 100644
>> >> --- a/drivers/media/usb/s2255/s2255drv.c
>> >> +++ b/drivers/media/usb/s2255/s2255drv.c
>> >> @@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface,
>> >>       dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
>> >>       if (dev->cmdbuf == NULL) {
>> >>               s2255_dev_err(&interface->dev, "out of memory\n");
>> >> +             kfree(dev);
>> >>               return -ENOMEM;
>> >>       }
>> >>
>> >
>> > The rest of the function already uses goto and labels for error handling. I
>> > think it'd take adding one more. dev is correctly released in other error
>> > cases.
>> I am not sure that adding a new label for error handling when
>> allocation for dev->cmdbuf is failed.
>> I think it is ok to me. :-) Because I think it is not good adding a
>> new label and use goto statement for this.
>
> I can ack this if you use the same pattern for error handling that's already
> there.
But it has a redundant kfree() call for dev->cmdbuf when it failed to
allocate, right?
If it is ok, I send this again after fixing as your comment.

Thanks.
Daeseok Youn.
>
> --
> Sakari Ailus
> e-mail: sakari.ailus@iki.fi     XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [media] s2255drv: fix memory leak s2255_probe()
  2014-05-07  4:38       ` DaeSeok Youn
@ 2014-05-08 11:21         ` Sakari Ailus
  0 siblings, 0 replies; 8+ messages in thread
From: Sakari Ailus @ 2014-05-08 11:21 UTC (permalink / raw)
  To: DaeSeok Youn; +Cc: m.chehab, linux-dev, hans.verkuil, linux-media, linux-kernel

On Wed, May 07, 2014 at 01:38:58PM +0900, DaeSeok Youn wrote:
> Hello,
> 
> 2014-05-05 17:38 GMT+09:00 Sakari Ailus <sakari.ailus@iki.fi>:
> > On Tue, Apr 15, 2014 at 07:54:43PM +0900, DaeSeok Youn wrote:
> >> Hi, Sakari
> >>
> >> 2014-04-15 18:33 GMT+09:00 Sakari Ailus <sakari.ailus@iki.fi>:
> >> > Hi Daeseok,
> >> >
> >> > On Tue, Apr 15, 2014 at 01:49:34PM +0900, Daeseok Youn wrote:
> >> >>
> >> >> smatch says:
> >> >>  drivers/media/usb/s2255/s2255drv.c:2246 s2255_probe() warn:
> >> >> possible memory leak of 'dev'
> >> >>
> >> >> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> >> >> ---
> >> >>  drivers/media/usb/s2255/s2255drv.c |    1 +
> >> >>  1 files changed, 1 insertions(+), 0 deletions(-)
> >> >>
> >> >> diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
> >> >> index 1d4ba2b..8aca3ef 100644
> >> >> --- a/drivers/media/usb/s2255/s2255drv.c
> >> >> +++ b/drivers/media/usb/s2255/s2255drv.c
> >> >> @@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface,
> >> >>       dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
> >> >>       if (dev->cmdbuf == NULL) {
> >> >>               s2255_dev_err(&interface->dev, "out of memory\n");
> >> >> +             kfree(dev);
> >> >>               return -ENOMEM;
> >> >>       }
> >> >>
> >> >
> >> > The rest of the function already uses goto and labels for error handling. I
> >> > think it'd take adding one more. dev is correctly released in other error
> >> > cases.
> >> I am not sure that adding a new label for error handling when
> >> allocation for dev->cmdbuf is failed.
> >> I think it is ok to me. :-) Because I think it is not good adding a
> >> new label and use goto statement for this.
> >
> > I can ack this if you use the same pattern for error handling that's already
> > there.
> But it has a redundant kfree() call for dev->cmdbuf when it failed to
> allocate, right?

Correct.

> If it is ok, I send this again after fixing as your comment.

Please do. Thanks.

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [media] s2255drv: fix memory leak s2255_probe()
  2014-05-08 22:57 Daeseok Youn
@ 2014-05-09  7:32 ` Sakari Ailus
  0 siblings, 0 replies; 8+ messages in thread
From: Sakari Ailus @ 2014-05-09  7:32 UTC (permalink / raw)
  To: Daeseok Youn; +Cc: m.chehab, linux-dev, hans.verkuil, linux-media, linux-kernel

Hi Daeseok,

Thanks for the update! :-)

On Fri, May 09, 2014 at 07:57:18AM +0900, Daeseok Youn wrote:
> smatch says:
>  drivers/media/usb/s2255/s2255drv.c:2246 s2255_probe() warn:
> possible memory leak of 'dev'
> 
> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> ---
> V2: use the same pattern for error handling.
> 
>  drivers/media/usb/s2255/s2255drv.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
> index 1d4ba2b..3193474 100644
> --- a/drivers/media/usb/s2255/s2255drv.c
> +++ b/drivers/media/usb/s2255/s2255drv.c
> @@ -2243,7 +2243,7 @@ static int s2255_probe(struct usb_interface *interface,
>  	dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
>  	if (dev->cmdbuf == NULL) {
>  		s2255_dev_err(&interface->dev, "out of memory\n");
> -		return -ENOMEM;
> +		goto errorFWDATA1;
>  	}
>  
>  	atomic_set(&dev->num_channels, 0);

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] [media] s2255drv: fix memory leak s2255_probe()
@ 2014-05-08 22:57 Daeseok Youn
  2014-05-09  7:32 ` Sakari Ailus
  0 siblings, 1 reply; 8+ messages in thread
From: Daeseok Youn @ 2014-05-08 22:57 UTC (permalink / raw)
  To: m.chehab; +Cc: sakari.ailus, linux-dev, hans.verkuil, linux-media, linux-kernel

smatch says:
 drivers/media/usb/s2255/s2255drv.c:2246 s2255_probe() warn:
possible memory leak of 'dev'

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
---
V2: use the same pattern for error handling.

 drivers/media/usb/s2255/s2255drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 1d4ba2b..3193474 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -2243,7 +2243,7 @@ static int s2255_probe(struct usb_interface *interface,
 	dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
 	if (dev->cmdbuf == NULL) {
 		s2255_dev_err(&interface->dev, "out of memory\n");
-		return -ENOMEM;
+		goto errorFWDATA1;
 	}
 
 	atomic_set(&dev->num_channels, 0);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-05-09  7:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-15  4:49 [PATCH] [media] s2255drv: fix memory leak s2255_probe() Daeseok Youn
2014-04-15  9:33 ` Sakari Ailus
2014-04-15 10:54   ` DaeSeok Youn
2014-05-05  8:38     ` Sakari Ailus
2014-05-07  4:38       ` DaeSeok Youn
2014-05-08 11:21         ` Sakari Ailus
2014-05-08 22:57 Daeseok Youn
2014-05-09  7:32 ` Sakari Ailus

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.