From mboxrd@z Thu Jan 1 00:00:00 1970 From: sergei.shtylyov@cogentembedded.com (Sergei Shtylyov) Date: Wed, 8 Jul 2015 15:03:23 +0300 Subject: [PATCH v2 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails In-Reply-To: <1436346323-31593-2-git-send-email-r.baldyga@samsung.com> References: <1436346323-31593-1-git-send-email-r.baldyga@samsung.com> <1436346323-31593-2-git-send-email-r.baldyga@samsung.com> Message-ID: <559D118B.3050607@cogentembedded.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933914AbbGHMDf (ORCPT ); Wed, 8 Jul 2015 08:03:35 -0400 Received: from mail-la0-f48.google.com ([209.85.215.48]:33916 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933349AbbGHMD2 (ORCPT ); Wed, 8 Jul 2015 08:03:28 -0400 Subject: Re: [PATCH v2 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails To: Robert Baldyga , gregkh@linuxfoundation.org, balbi@ti.com References: <1436346323-31593-1-git-send-email-r.baldyga@samsung.com> <1436346323-31593-2-git-send-email-r.baldyga@samsung.com> Cc: nicolas.ferre@atmel.com, dan.carpenter@oracle.com, mina86@mina86.com, andrzej.p@samsung.com, m.szyprowski@samsung.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org From: Sergei Shtylyov Message-ID: <559D118B.3050607@cogentembedded.com> Date: Wed, 8 Jul 2015 15:03:23 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <1436346323-31593-2-git-send-email-r.baldyga@samsung.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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