linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* list not released in case of -ENODEV in hidraw_release (hidraw.c)
@ 2011-06-22  7:58 Amit Nagal
       [not found] ` <BANLkTi=Teg9iN8osSDY9fqadZ+sA-Ng2Sw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Nagal @ 2011-06-22  7:58 UTC (permalink / raw)
  To: linux-usb, linux-input; +Cc: Jiri Kosina

Hi ,

linux kernel ver 2.6.39.1  ,  hidraw.c  , in  hidraw_release function
, list pointer ( struct hidraw_list *list ) is not freed
in case of -ENODEV .

i think the following patch is applicable :

--- a/drivers/hid/hidraw.c	2011-06-22 08:57:55.000000000 -0400
+++ b/drivers/hid/hidraw.c	2011-06-22 08:42:04.000000000 -0400
@@ -298,6 +298,7 @@ static int hidraw_release(struct inode *

 	mutex_lock(&minors_lock);
 	if (!hidraw_table[minor]) {
+		kfree(list);
 		ret = -ENODEV;
 		goto unlock;
 	}

Please correct me if i am mistaken .

Regards
Amit Nagal

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

* Re: list not released in case of -ENODEV in hidraw_release (hidraw.c)
       [not found] ` <BANLkTi=Teg9iN8osSDY9fqadZ+sA-Ng2Sw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-06-22 11:43   ` Amit Nagal
  2011-07-22 14:36     ` Jiri Kosina
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Nagal @ 2011-06-22 11:43 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA
  Cc: Jiri Kosina, Alan Ott, Antonio Ospite

On Wed, Jun 22, 2011 at 1:28 PM, Amit Nagal <helloin.amit-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hi ,
>
> linux kernel ver 2.6.39.1  ,  hidraw.c  , in  hidraw_release function
> , list pointer ( struct hidraw_list *list ) is not freed
> in case of -ENODEV .
>
> i think the following patch is applicable :
>
> --- a/drivers/hid/hidraw.c      2011-06-22 08:57:55.000000000 -0400
> +++ b/drivers/hid/hidraw.c      2011-06-22 08:42:04.000000000 -0400
> @@ -298,6 +298,7 @@ static int hidraw_release(struct inode *
>
>        mutex_lock(&minors_lock);
>        if (!hidraw_table[minor]) {
> +               kfree(list);
>                ret = -ENODEV;
>                goto unlock;
>        }
>
> Please correct me if i am mistaken .
>

In continuation of above , in hidraw_release(), for the sequence
disconnect  followed by last userspace close(fd) call ,
even kfree(list->hidraw) should also be called , as in
hidraw_disconnect() function kfree(hidraw) is called only when
hidraw->open is 0 .
so list->hidraw should also be freed when calling last close() call
even after disconnect .

if i have misunderstood facts , kindly clear my doubts .


Regards
Amit Nagal
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: list not released in case of -ENODEV in hidraw_release (hidraw.c)
  2011-06-22 11:43   ` Amit Nagal
@ 2011-07-22 14:36     ` Jiri Kosina
  2011-07-27  4:03       ` Amit Nagal
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Kosina @ 2011-07-22 14:36 UTC (permalink / raw)
  To: Amit Nagal; +Cc: linux-usb, linux-input, Alan Ott, Antonio Ospite

On Wed, 22 Jun 2011, Amit Nagal wrote:

> > linux kernel ver 2.6.39.1  ,  hidraw.c  , in  hidraw_release function
> > , list pointer ( struct hidraw_list *list ) is not freed
> > in case of -ENODEV .
> >
> > i think the following patch is applicable :
> >
> > --- a/drivers/hid/hidraw.c      2011-06-22 08:57:55.000000000 -0400
> > +++ b/drivers/hid/hidraw.c      2011-06-22 08:42:04.000000000 -0400
> > @@ -298,6 +298,7 @@ static int hidraw_release(struct inode *
> >
> >        mutex_lock(&minors_lock);
> >        if (!hidraw_table[minor]) {
> > +               kfree(list);
> >                ret = -ENODEV;
> >                goto unlock;
> >        }
> >
> > Please correct me if i am mistaken .
> >
> 
> In continuation of above , in hidraw_release(), for the sequence
> disconnect  followed by last userspace close(fd) call ,
> even kfree(list->hidraw) should also be called , as in
> hidraw_disconnect() function kfree(hidraw) is called only when
> hidraw->open is 0 .
> so list->hidraw should also be freed when calling last close() call
> even after disconnect .

Hi Amit,

your analysis is correct. Could you please re-send the patch with the 
other fixes added, and also your Signed-off-by line?

Thanks,

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: list not released in case of -ENODEV in hidraw_release (hidraw.c)
  2011-07-22 14:36     ` Jiri Kosina
@ 2011-07-27  4:03       ` Amit Nagal
  0 siblings, 0 replies; 4+ messages in thread
From: Amit Nagal @ 2011-07-27  4:03 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-usb, linux-input, Alan Ott, Antonio Ospite

On Fri, Jul 22, 2011 at 8:06 PM, Jiri Kosina <jkosina@suse.cz> wrote:
> On Wed, 22 Jun 2011, Amit Nagal wrote:
>
>> > linux kernel ver 2.6.39.1  ,  hidraw.c  , in  hidraw_release function
>> > , list pointer ( struct hidraw_list *list ) is not freed
>> > in case of -ENODEV .
>> >
>> > i think the following patch is applicable :
>> >
>> > --- a/drivers/hid/hidraw.c      2011-06-22 08:57:55.000000000 -0400
>> > +++ b/drivers/hid/hidraw.c      2011-06-22 08:42:04.000000000 -0400
>> > @@ -298,6 +298,7 @@ static int hidraw_release(struct inode *
>> >
>> >        mutex_lock(&minors_lock);
>> >        if (!hidraw_table[minor]) {
>> > +               kfree(list);
>> >                ret = -ENODEV;
>> >                goto unlock;
>> >        }
>> >
>> > Please correct me if i am mistaken .
>> >
>>
>> In continuation of above , in hidraw_release(), for the sequence
>> disconnect  followed by last userspace close(fd) call ,
>> even kfree(list->hidraw) should also be called , as in
>> hidraw_disconnect() function kfree(hidraw) is called only when
>> hidraw->open is 0 .
>> so list->hidraw should also be freed when calling last close() call
>> even after disconnect .
>
> Hi Amit,
>
> your analysis is correct. Could you please re-send the patch with the
> other fixes added, and also your Signed-off-by line?
>
> Thanks,
>
> --
> Jiri Kosina
> SUSE Labs
>


Thanx for reviewing my analysis . i will resubmit the patch after
adding other fixes as well .

Regards
Amit Nagal
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2011-07-27  4:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-22  7:58 list not released in case of -ENODEV in hidraw_release (hidraw.c) Amit Nagal
     [not found] ` <BANLkTi=Teg9iN8osSDY9fqadZ+sA-Ng2Sw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-22 11:43   ` Amit Nagal
2011-07-22 14:36     ` Jiri Kosina
2011-07-27  4:03       ` Amit Nagal

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).