Re: [PATCH v2 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails

2015-07-08 Thread Michal Nazarewicz
On Wed, Jul 08 2015, Robert Baldyga wrote:
> Function ffs_do_functionfs_bind() calls functionfs_bind() which allocates
> usb request and increments refcounts. These things needs to be cleaned
> up by if further steps of initialization fail by calling functionfs_unbind().
>
> Signed-off-by: Robert Baldyga 

Acked-by: Michal Nazarewicz 

> ---
>  drivers/usb/gadget/function/f_fs.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c 
> b/drivers/usb/gadget/function/f_fs.c
> index 6e7be91..6516187 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -2897,11 +2897,18 @@ static int ffs_func_bind(struct usb_configuration *c,
>struct usb_function *f)
>  {
>   struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c);
> + struct ffs_function *func = ffs_func_from_usb(f);
> + int ret;
>  
>   if (IS_ERR(ffs_opts))
>   return PTR_ERR(ffs_opts);
>  
> - return _ffs_func_bind(c, f);
> + ret = _ffs_func_bind(c, f);
> + if (ret)
> + if(!--ffs_opts->refcnt)
> + functionfs_unbind(func->ffs);
> +
> + return ret;
>  }
>  
>  
> -- 
> 1.9.1
>

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails

2015-07-08 Thread Sergei Shtylyov

Hello.

On 7/8/2015 12:05 PM, Robert Baldyga wrote:


Function ffs_do_functionfs_bind() calls functionfs_bind() which allocates
usb request and increments refcounts. These things needs to be cleaned
up by if further steps of initialization fail by calling functionfs_unbind().



Signed-off-by: Robert Baldyga 
---
  drivers/usb/gadget/function/f_fs.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)



diff --git a/drivers/usb/gadget/function/f_fs.c 
b/drivers/usb/gadget/function/f_fs.c
index 6e7be91..6516187 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2897,11 +2897,18 @@ static int ffs_func_bind(struct usb_configuration *c,
 struct usb_function *f)
  {
struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c);
+   struct ffs_function *func = ffs_func_from_usb(f);
+   int ret;

if (IS_ERR(ffs_opts))
return PTR_ERR(ffs_opts);

-   return _ffs_func_bind(c, f);
+   ret = _ffs_func_bind(c, f);
+   if (ret)
+   if(!--ffs_opts->refcnt)
+   functionfs_unbind(func->ffs);


   Hum, I think you need {} around the outer *if* clause. Either that, or 
just fold two *if* statments together.



+
+   return ret;
  }

[...]

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails

2015-07-08 Thread Robert Baldyga
Function ffs_do_functionfs_bind() calls functionfs_bind() which allocates
usb request and increments refcounts. These things needs to be cleaned
up by if further steps of initialization fail by calling functionfs_unbind().

Signed-off-by: Robert Baldyga 
---
 drivers/usb/gadget/function/f_fs.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_fs.c 
b/drivers/usb/gadget/function/f_fs.c
index 6e7be91..6516187 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2897,11 +2897,18 @@ static int ffs_func_bind(struct usb_configuration *c,
 struct usb_function *f)
 {
struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c);
+   struct ffs_function *func = ffs_func_from_usb(f);
+   int ret;
 
if (IS_ERR(ffs_opts))
return PTR_ERR(ffs_opts);
 
-   return _ffs_func_bind(c, f);
+   ret = _ffs_func_bind(c, f);
+   if (ret)
+   if(!--ffs_opts->refcnt)
+   functionfs_unbind(func->ffs);
+
+   return ret;
 }
 
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/