From: Felipe Balbi <balbi@kernel.org>
To: Vegard Nossum <vegard.nossum@oracle.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Ruslan Bilovol <ruslan.bilovol@gmail.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Peter Chen <peter.chen@freescale.com>
Subject: Re: [PATCH] usb: gadget: gadgetfs: unregister gadget only if it got successfully registered
Date: Wed, 17 Feb 2016 16:48:51 +0200 [thread overview]
Message-ID: <87twl7gzos.fsf@ti.com> (raw)
In-Reply-To: <56B88B0B.8020503@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 1999 bytes --]
Hi,
Vegard Nossum <vegard.nossum@oracle.com> writes:
> On 02/08/2016 01:15 PM, Marek Szyprowski wrote:
>> Gadgetfs driver called usb_gadget_unregister_driver unconditionally, even
>> if it didn't register it earlier due to other failures. This patch fixes
>> this.
>>
>> Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>> ---
>> drivers/usb/gadget/legacy/inode.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
>> index 7a62a2f7bc18..cde6a2133c90 100644
>> --- a/drivers/usb/gadget/legacy/inode.c
>> +++ b/drivers/usb/gadget/legacy/inode.c
>> @@ -130,7 +130,8 @@ struct dev_data {
>> setup_can_stall : 1,
>> setup_out_ready : 1,
>> setup_out_error : 1,
>> - setup_abort : 1;
>> + setup_abort : 1,
>> + gadget_registered : 1;
>> unsigned setup_wLength;
>>
>> /* the rest is basically write-once */
>> @@ -1179,7 +1180,8 @@ dev_release (struct inode *inode, struct file *fd)
>>
>> /* closing ep0 === shutdown all */
>>
>> - usb_gadget_unregister_driver (&gadgetfs_driver);
>> + if (dev->gadget_registered)
>> + usb_gadget_unregister_driver (&gadgetfs_driver);
>>
>> /* at this point "good" hardware has disconnected the
>> * device from USB; the host won't see it any more.
>> @@ -1825,6 +1827,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
>> * kick in after the ep0 descriptor is closed.
>> */
>> value = len;
>> + dev->gadget_registered = true;
>> }
>> return value;
>>
>>
>
> That (along with the first patch) fixes the problem! Thanks.
>
> It also seems to have fixed another crash I was seeing with
> req->complete == NULL in usb_gadget_giveback_request().
please resend both patches with proper Acks and Tested-bys so I can
apply them.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
next prev parent reply other threads:[~2016-02-17 14:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-07 23:27 gadgetfs regression (NULL ptr deref) since v4.4-rc7 Vegard Nossum
2016-02-08 9:46 ` Ruslan Bilovol
2016-02-08 10:19 ` Marek Szyprowski
2016-02-08 11:07 ` Vegard Nossum
2016-02-08 11:12 ` [PATCH] usb: gadget: provide interface for legacy gadgets to get UDC name Marek Szyprowski
2016-02-08 11:31 ` Vegard Nossum
2016-02-08 12:26 ` [PATCH v2] " Marek Szyprowski
2016-02-08 12:29 ` [PATCH] " Marek Szyprowski
2016-02-18 10:34 ` [PATCH v3] " Marek Szyprowski
2016-02-08 12:15 ` [PATCH] usb: gadget: gadgetfs: unregister gadget only if it got successfully registered Marek Szyprowski
2016-02-08 12:33 ` Vegard Nossum
2016-02-17 14:48 ` Felipe Balbi [this message]
2016-02-18 7:58 ` [PATCH v2 RESEND] usb: gadget: provide interface for legacy gadgets to get UDC name Marek Szyprowski
2016-02-18 8:11 ` Felipe Balbi
2016-02-18 7:59 ` [PATCH RESEND] usb: gadget: gadgetfs: unregister gadget only if it got successfully registered Marek Szyprowski
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=87twl7gzos.fsf@ti.com \
--to=balbi@kernel.org \
--cc=b.zolnierkie@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=maxime.ripard@free-electrons.com \
--cc=peter.chen@freescale.com \
--cc=ruslan.bilovol@gmail.com \
--cc=vegard.nossum@oracle.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).