lkml.org 
[lkml]   [2012]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: kernel panic when called usb_control_msg()
On Fri, 3 Aug 2012, y b wrote:

> Hi,
> kernel panic when called usb_control_msg(), like this:
> usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
> XR_SET_REG, USB_DIR_OUT | USB_TYPE_VENDOR, value, regnum | (block <<
> 8), NULL, 0, 5000)
> The kernel's version is 2.6.33_rc4, but I think it will happen in
> lastest statable version too.

> I fixed it like this:
>
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index 4bb717d..b043f27 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
> @@ -2056,9 +2056,15 @@ static int musb_urb_enqueue(
> kfree(qh);
> qh = NULL;
> ret = 0;
> - } else
> - ret = musb_schedule(musb, qh,
> - epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK);
> + } else {
> + if (!next_urb(qh)) {
> + kfree(qh);
> + qh = NULL;
> + ret = 0;
> + } else
> + ret = musb_schedule(musb, qh,
> + epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK);
> + }
>

You could shrink this patch a lot:

* we only have work to do in the former case.
*/
spin_lock_irqsave(&musb->lock, flags);
- if (hep->hcpriv) {
+ if (hep->hcpriv || !next_urb(qh)) {
/* some concurrent activity submitted another urb to hep...
* odd, rare, error prone, but legal.
*/

Alan Stern



\
 
 \ /
  Last update: 2012-08-03 17:21    [W:0.081 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site