diff options
| author | Robert Baldyga <r.baldyga@samsung.com> | 2015-07-13 11:03:50 +0200 |
|---|---|---|
| committer | Felipe Balbi <balbi@ti.com> | 2015-07-31 08:57:57 -0500 |
| commit | 55d811211b139ed097ddaf40d173c258f133c130 (patch) | |
| tree | b043306a7b0793dc2998226ea3ad415645a5445e | |
| parent | 913e4a90b6f9687ac0f543e7b632753e4f51c441 (diff) | |
usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails
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 <r.baldyga@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
| -rw-r--r-- | drivers/usb/gadget/function/f_fs.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 6e7be91e6097..adc6d52efa46 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2897,11 +2897,17 @@ 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 && !--ffs_opts->refcnt) + functionfs_unbind(func->ffs); + + return ret; } |
