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


Groups > linux.kernel > #1459422 > unrolled thread

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

Started byAlan Stern <stern@rowland.harvard.edu>
First post2016-08-10 20:30 +0200
Last post2016-08-10 20:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2 1/1] usb: misc: usbtest: add fix for driver hang Alan Stern <stern@rowland.harvard.edu> - 2016-08-10 20:30 +0200

#1459422 — Re: [PATCH v2 1/1] usb: misc: usbtest: add fix for driver hang

FromAlan Stern <stern@rowland.harvard.edu>
Date2016-08-10 20:30 +0200
SubjectRe: [PATCH v2 1/1] usb: misc: usbtest: add fix for driver hang
Message-ID<s4Gqn-b4-91@gated-at.bofh.it>
On Wed, 10 Aug 2016, Lu Baolu wrote:

> 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 whenever transfer time out is triggered.
> 
> This patch fixes this issue. It could be backported to stable kernel
> with version later than v3.15.
> 
> Cc: stable@vger.kernel.org # 3.15+
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
>  v1->v2:
>  - Set retval to -ETIMEDOUT after timed out
>  - Removed the kernel log in patch description
> 
>  drivers/usb/misc/usbtest.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> index 6b978f0..c273e11 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);
>  }
>  
> @@ -616,8 +615,10 @@ static int perform_sglist(
>  		mod_timer(&sg_timer, jiffies +
>  				msecs_to_jiffies(SIMPLE_IO_TIMEOUT));
>  		usb_sg_wait(req);
> -		del_timer_sync(&sg_timer);
> -		retval = req->status;
> +		if (unlikely(!del_timer_sync(&sg_timer)))
> +			retval = -ETIMEDOUT;
> +		else
> +			retval = req->status;
>  
>  		/* FIXME check resulting data pattern */

I wouldn't bother with the "unlikely()" because this isn't a hot path.  
Aside from that,

Acked-by: Alan Stern <stern@rowland.harvard.edu>

Alan Stern

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web