public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: sergei.shtylyov@cogentembedded•com (Sergei Shtylyov)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v2 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails
Date: Wed, 8 Jul 2015 15:03:23 +0300	[thread overview]
Message-ID: <559D118B.3050607@cogentembedded.com> (raw)
In-Reply-To: <1436346323-31593-2-git-send-email-r.baldyga@samsung.com>

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 <r.baldyga@samsung•com>
> ---
>   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

  reply	other threads:[~2015-07-08 12:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08  9:05 [PATCH v2 0/5] usb: gadget: miscellaneous fixes Robert Baldyga
2015-07-08  9:05 ` [PATCH v2 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails Robert Baldyga
2015-07-08 12:03   ` Sergei Shtylyov [this message]
2015-07-08 13:44   ` Michal Nazarewicz
2015-07-08  9:05 ` [PATCH v2 2/5] usb: gadget: midi: avoid redundant f_midi_set_alt() call Robert Baldyga
2015-07-08 13:45   ` Michal Nazarewicz
2015-07-08  9:05 ` [PATCH v2 3/5] usb: isp1760: udc: add missing usb_ep_set_maxpacket_limit() Robert Baldyga
2015-07-08 13:46   ` Michal Nazarewicz
2015-07-08  9:05 ` [PATCH v2 4/5] staging: emxx_udc: " Robert Baldyga
2015-07-08 13:47   ` Michal Nazarewicz
2015-07-08  9:05 ` [PATCH v2 5/5] usb: gadget: atmel_usba_udc: add missing ret value check Robert Baldyga
2015-07-08 13:47   ` Michal Nazarewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=559D118B.3050607@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox