linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: f_fs: remove redundant ffs_data_get()
@ 2014-10-09  7:41 Robert Baldyga
  2014-10-09 10:39 ` Michal Nazarewicz
  2014-10-09 14:21 ` Felipe Balbi
  0 siblings, 2 replies; 4+ messages in thread
From: Robert Baldyga @ 2014-10-09  7:41 UTC (permalink / raw)
  To: balbi
  Cc: gregkh, linux-usb, linux-kernel, mina86, andrzej.p, m.szyprowski,
	Robert Baldyga

During FunctionFS bind, ffs_data_get() function was called twice
(in functionfs_bind() and in ffs_do_functionfs_bind()), while on unbind
ffs_data_put() was called once (in functionfs_unbind() function).
In result refcount never reached value 0, and ffs memory resources has
been never released.

Since ffs_data_get() call in ffs_do_functionfs_bind() is redundant
and not neccessary, we remove it to have equal number of gets ans puts,
and free allocated memory after refcount reach 0.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/usb/gadget/function/f_fs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 7c6771d..12dbdaf 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2663,8 +2663,6 @@ static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
 	func->conf = c;
 	func->gadget = c->cdev->gadget;
 
-	ffs_data_get(func->ffs);
-
 	/*
 	 * in drivers/usb/gadget/configfs.c:configfs_composite_bind()
 	 * configurations are bound in sequence with list_for_each_entry,
-- 
1.9.1


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

* Re: [PATCH] usb: gadget: f_fs: remove redundant ffs_data_get()
  2014-10-09  7:41 [PATCH] usb: gadget: f_fs: remove redundant ffs_data_get() Robert Baldyga
@ 2014-10-09 10:39 ` Michal Nazarewicz
  2014-10-09 14:21 ` Felipe Balbi
  1 sibling, 0 replies; 4+ messages in thread
From: Michal Nazarewicz @ 2014-10-09 10:39 UTC (permalink / raw)
  To: Robert Baldyga, balbi
  Cc: gregkh, linux-usb, linux-kernel, andrzej.p, m.szyprowski,
	Robert Baldyga

On Thu, Oct 09 2014, Robert Baldyga <r.baldyga@samsung.com> wrote:
> During FunctionFS bind, ffs_data_get() function was called twice
> (in functionfs_bind() and in ffs_do_functionfs_bind()), while on unbind
> ffs_data_put() was called once (in functionfs_unbind() function).
> In result refcount never reached value 0, and ffs memory resources has
> been never released.
>
> Since ffs_data_get() call in ffs_do_functionfs_bind() is redundant
> and not neccessary, we remove it to have equal number of gets ans puts,
> and free allocated memory after refcount reach 0.
>
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> ---
>  drivers/usb/gadget/function/f_fs.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 7c6771d..12dbdaf 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -2663,8 +2663,6 @@ static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
>  	func->conf = c;
>  	func->gadget = c->cdev->gadget;
>  
> -	ffs_data_get(func->ffs);
> -
>  	/*
>  	 * in drivers/usb/gadget/configfs.c:configfs_composite_bind()
>  	 * configurations are bound in sequence with list_for_each_entry,
> -- 
> 1.9.1
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--

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

* Re: [PATCH] usb: gadget: f_fs: remove redundant ffs_data_get()
  2014-10-09  7:41 [PATCH] usb: gadget: f_fs: remove redundant ffs_data_get() Robert Baldyga
  2014-10-09 10:39 ` Michal Nazarewicz
@ 2014-10-09 14:21 ` Felipe Balbi
  2014-10-10  5:17   ` Robert Baldyga
  1 sibling, 1 reply; 4+ messages in thread
From: Felipe Balbi @ 2014-10-09 14:21 UTC (permalink / raw)
  To: Robert Baldyga
  Cc: balbi, gregkh, linux-usb, linux-kernel, mina86, andrzej.p,
	m.szyprowski

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]

On Thu, Oct 09, 2014 at 09:41:16AM +0200, Robert Baldyga wrote:
> During FunctionFS bind, ffs_data_get() function was called twice
> (in functionfs_bind() and in ffs_do_functionfs_bind()), while on unbind
> ffs_data_put() was called once (in functionfs_unbind() function).
> In result refcount never reached value 0, and ffs memory resources has
> been never released.
> 
> Since ffs_data_get() call in ffs_do_functionfs_bind() is redundant
> and not neccessary, we remove it to have equal number of gets ans puts,
> and free allocated memory after refcount reach 0.
> 
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>

Which commit is this fixing ? does it deserve a stable backport ? How
far back ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] usb: gadget: f_fs: remove redundant ffs_data_get()
  2014-10-09 14:21 ` Felipe Balbi
@ 2014-10-10  5:17   ` Robert Baldyga
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Baldyga @ 2014-10-10  5:17 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-kernel, mina86, andrzej.p, m.szyprowski

On 10/09/2014 04:21 PM, Felipe Balbi wrote:
> On Thu, Oct 09, 2014 at 09:41:16AM +0200, Robert Baldyga wrote:
>> During FunctionFS bind, ffs_data_get() function was called twice
>> (in functionfs_bind() and in ffs_do_functionfs_bind()), while on unbind
>> ffs_data_put() was called once (in functionfs_unbind() function).
>> In result refcount never reached value 0, and ffs memory resources has
>> been never released.
>>
>> Since ffs_data_get() call in ffs_do_functionfs_bind() is redundant
>> and not neccessary, we remove it to have equal number of gets ans puts,
>> and free allocated memory after refcount reach 0.
>>
>> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
> 
> Which commit is this fixing ? does it deserve a stable backport ? How
> far back ?
> 

The problem starts with commit 5920cda627688c3229fd63157ff031f3f174175e
[usb: gadget: FunctionFS: convert to new function interface with
backward compatibility].

This bug causes memory leak so I think it should be in stable too.

Thanks,
Robert Baldyga

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

end of thread, other threads:[~2014-10-10  5:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-09  7:41 [PATCH] usb: gadget: f_fs: remove redundant ffs_data_get() Robert Baldyga
2014-10-09 10:39 ` Michal Nazarewicz
2014-10-09 14:21 ` Felipe Balbi
2014-10-10  5:17   ` Robert Baldyga

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