Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1458793

Re: [PATCH 1/1] usb: misc: usbtest: add fix for driver hang

From Alan Stern <stern@rowland.harvard.edu>
Newsgroups linux.kernel
Subject Re: [PATCH 1/1] usb: misc: usbtest: add fix for driver hang
Date 2016-08-09 16:20 +0200
Message-ID <s4g2R-fu-13@gated-at.bofh.it> (permalink)
References <s4bmx-5B6-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 9 Aug 2016, Felipe Balbi wrote:

> 
> Hi,
> 
> Lu Baolu <baolu.lu@linux.intel.com> writes:
> > In sg_timeout(), req->status is set to "-ETIMEDOUT" before calling
> > into usb_sg_cancel(). usb_sg_cancel() will do nothing and return
> > directly if req->status has been set to a non-zero value. This will
> > cause driver hang as soon as transfer time out is triggered.

...

> > This patch fixes this driver hang. It should be back-ported to stable
> > kernel with version after v3.15.
> >
> > Cc: stable@vger.kernel.org
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> > ---
> >  drivers/usb/misc/usbtest.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> > index 6b978f0..6c6586d 100644
> > --- a/drivers/usb/misc/usbtest.c
> > +++ b/drivers/usb/misc/usbtest.c
> > @@ -585,7 +585,6 @@ static void sg_timeout(unsigned long _req)
> >  {
> >  	struct usb_sg_request	*req = (struct usb_sg_request *) _req;
> >  
> > -	req->status = -ETIMEDOUT;
> >  	usb_sg_cancel(req);
> >  }
> 
> IMO, req->status = -ETIMEDOUT should still be done, but perhaps after
> usb_sg_cancel(). Alan?

That would race with sg_complete(), perhaps causing a bunch of error
messages.  A better approach would be to delete the assignment as
above and then change perform_sglist():

 		usb_sg_wait(req);
-		del_timer_sync(&sg_timer);
 		retval = req->status;
+		if (!del_timer_sync(&sg_timer))
+			retval = -ETIMEDOUT;

Alan Stern

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/1] usb: misc: usbtest: add fix for driver hang Lu Baolu <baolu.lu@linux.intel.com> - 2016-08-09 07:10 +0200
  Re: [PATCH 1/1] usb: misc: usbtest: add fix for driver hang Felipe Balbi <felipe.balbi@linux.intel.com> - 2016-08-09 11:20 +0200
    Re: [PATCH 1/1] usb: misc: usbtest: add fix for driver hang Alan Stern <stern@rowland.harvard.edu> - 2016-08-09 16:20 +0200
      Re: [PATCH 1/1] usb: misc: usbtest: add fix for driver hang Lu Baolu <baolu.lu@linux.intel.com> - 2016-08-10 20:50 +0200

csiph-web