All of lore.kernel.org
 help / color / mirror / Atom feed
From: r.baldyga@hackerion.com (Robert Baldyga)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails
Date: Tue, 07 Jul 2015 18:00:27 +0200	[thread overview]
Message-ID: <559BF79B.903@hackerion.com> (raw)
In-Reply-To: <20150707145345.GD4341@mwanda>

On 07/07/2015 04:53 PM, Dan Carpenter wrote:
> On Tue, Jul 07, 2015 at 04:02:49PM +0200, Robert Baldyga wrote:
>> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
>> index 6e7be91..966b214 100644
>> --- a/drivers/usb/gadget/function/f_fs.c
>> +++ b/drivers/usb/gadget/function/f_fs.c
>> @@ -2897,11 +2897,19 @@ 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--;
>
> Wait, why are we decrementing here?  ffs_func_unbind() already has a
> decrement so this looks like a bug to me.  Add a comment if it's really
> needed.

Decrement is done in ffs_func_unbind() which is not called in this error 
path. But after all I see another problem here, because we shouldn't 
call functionfs_unbind() if refcnt after decrement is not equal zero. I 
will fix it.

>
>> +		functionfs_unbind(func->ffs);

Thanks,
Robert Baldyga

WARNING: multiple messages have this Message-ID (diff)
From: Robert Baldyga <r.baldyga@hackerion.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Robert Baldyga <r.baldyga@samsung.com>
Cc: gregkh@linuxfoundation.org, balbi@ti.com,
	devel@driverdev.osuosl.org, hamohammed.sa@gmail.com,
	chris@rorvick.com, tapaswenipathak@gmail.com,
	linux-usb@vger.kernel.org, nicolas.ferre@atmel.com,
	hgujulan@visteon.com, mina86@mina86.com,
	linux-kernel@vger.kernel.org, vinc94@gmail.com,
	roberta.dobrescu@gmail.com, andrzej.p@samsung.com,
	linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com
Subject: Re: [PATCH 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails
Date: Tue, 07 Jul 2015 18:00:27 +0200	[thread overview]
Message-ID: <559BF79B.903@hackerion.com> (raw)
In-Reply-To: <20150707145345.GD4341@mwanda>

On 07/07/2015 04:53 PM, Dan Carpenter wrote:
> On Tue, Jul 07, 2015 at 04:02:49PM +0200, Robert Baldyga wrote:
>> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
>> index 6e7be91..966b214 100644
>> --- a/drivers/usb/gadget/function/f_fs.c
>> +++ b/drivers/usb/gadget/function/f_fs.c
>> @@ -2897,11 +2897,19 @@ 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--;
>
> Wait, why are we decrementing here?  ffs_func_unbind() already has a
> decrement so this looks like a bug to me.  Add a comment if it's really
> needed.

Decrement is done in ffs_func_unbind() which is not called in this error 
path. But after all I see another problem here, because we shouldn't 
call functionfs_unbind() if refcnt after decrement is not equal zero. I 
will fix it.

>
>> +		functionfs_unbind(func->ffs);

Thanks,
Robert Baldyga


  reply	other threads:[~2015-07-07 16:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 14:02 [PATCH 0/5] usb: gadget: miscellaneous fixes Robert Baldyga
2015-07-07 14:02 ` Robert Baldyga
2015-07-07 14:02 ` [PATCH 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails Robert Baldyga
2015-07-07 14:02   ` Robert Baldyga
2015-07-07 14:53   ` Dan Carpenter
2015-07-07 14:53     ` Dan Carpenter
2015-07-07 16:00     ` Robert Baldyga [this message]
2015-07-07 16:00       ` Robert Baldyga
2015-07-08  7:55       ` Dan Carpenter
2015-07-08  7:55         ` Dan Carpenter
2015-07-07 14:02 ` [PATCH 2/5] usb: gadget: midi: avoid redundant f_midi_set_alt() call Robert Baldyga
2015-07-07 14:02   ` Robert Baldyga
2015-07-07 14:02 ` [PATCH 3/5] usb: isp1760: udc: add missing usb_ep_set_maxpacket_limit() Robert Baldyga
2015-07-07 14:02   ` Robert Baldyga
2015-07-07 15:01   ` Dan Carpenter
2015-07-07 15:01     ` Dan Carpenter
2015-07-07 16:24     ` Robert Baldyga
2015-07-07 16:24       ` Robert Baldyga
2015-07-07 14:02 ` [PATCH 4/5] staging: emxx_udc: " Robert Baldyga
2015-07-07 14:02   ` Robert Baldyga
2015-07-07 14:10   ` Sergei Shtylyov
2015-07-07 14:10     ` Sergei Shtylyov
2015-07-07 15:03   ` Dan Carpenter
2015-07-07 15:03     ` Dan Carpenter
2015-07-07 14:02 ` [PATCH 5/5] usb: gadget: atmel_usba_udc: add missing ret value check Robert Baldyga
2015-07-07 14:02   ` Robert Baldyga
2015-07-08  8:20   ` Nicolas Ferre
2015-07-08  8:20     ` Nicolas Ferre

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=559BF79B.903@hackerion.com \
    --to=r.baldyga@hackerion.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.