From: Peter Chen <peter.chen@freescale.com>
To: Robert Baldyga <r.baldyga@samsung.com>
Cc: <balbi@ti.com>, <gregkh@linuxfoundation.org>,
<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<m.szyprowski@samsung.com>, <k.opasiak@samsung.com>
Subject: Re: [PATCH] usb: gadget: udc-core: call udc_stop() before gadget unbind
Date: Mon, 15 Dec 2014 13:13:18 +0800 [thread overview]
Message-ID: <20141215051317.GC25410@shlinux2> (raw)
In-Reply-To: <1418390248-6254-1-git-send-email-r.baldyga@samsung.com>
On Fri, Dec 12, 2014 at 02:17:28PM +0100, Robert Baldyga wrote:
> As usb function drivers assumes that all usb request will be completed
> before function unbind call, we should supply such behavior. In some
> cases ep_disable() won't kill all request effectively, because some
> IN requests can be in running state. In such situation it's possible
> to have unbind function called before last request completion, which
> can cause problems.
Doesn't the function's disable/unbind should call usb_ep_dequeue to make
sure the transfer has ended?
.udc_stop may stop the controller, and .unbind may still visit hardware.
>
> For example unbinding f_ecm function while request on 'notify' endpoint
> is not completed, ends up NULL pointer dereference in unbind() function.
>
> usb_gadget_udc_stop() call causes completion of all requests so if it's
> called before gadget unbind there is no risk that some of requests will
> stay uncompleted.
>
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
> ---
> drivers/usb/gadget/udc/udc-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
> index e31d574..6f0d233 100644
> --- a/drivers/usb/gadget/udc/udc-core.c
> +++ b/drivers/usb/gadget/udc/udc-core.c
> @@ -331,8 +331,8 @@ static void usb_gadget_remove_driver(struct usb_udc *udc)
>
> usb_gadget_disconnect(udc->gadget);
> udc->driver->disconnect(udc->gadget);
> - udc->driver->unbind(udc->gadget);
> usb_gadget_udc_stop(udc);
> + udc->driver->unbind(udc->gadget);
>
> udc->driver = NULL;
> udc->dev.driver = NULL;
> --
> 1.9.1
>
--
Best Regards,
Peter Chen
next prev parent reply other threads:[~2014-12-15 6:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 13:17 [PATCH] usb: gadget: udc-core: call udc_stop() before gadget unbind Robert Baldyga
2014-12-12 13:51 ` Krzysztof Opasiak
2014-12-15 5:13 ` Peter Chen [this message]
2014-12-15 10:05 ` Robert Baldyga
2014-12-22 16:34 ` Felipe Balbi
2014-12-23 6:34 ` Robert Baldyga
2014-12-23 18:31 ` Felipe Balbi
2014-12-29 7:30 ` Robert Baldyga
2014-12-29 16:39 ` Felipe Balbi
2014-12-15 16:14 ` Alan Stern
2014-12-22 16:32 ` Felipe Balbi
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=20141215051317.GC25410@shlinux2 \
--to=peter.chen@freescale.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=k.opasiak@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=r.baldyga@samsung.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