From: Lu Baolu <baolu.lu@linux.intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2 1/1] usb: misc: usbtest: add fix for driver hang
Date: Thu, 11 Aug 2016 09:24:05 +0800 [thread overview]
Message-ID: <57ABD3B5.8020805@linux.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1608101015110.1843-100000@iolanthe.rowland.org>
Hi,
On 08/10/2016 10:16 PM, Alan Stern wrote:
> 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>
Thank you. I will remove "unlikely()" in new version.
Best regards,
Lu Baolu
prev parent reply other threads:[~2016-08-11 1:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-10 5:42 [PATCH v2 1/1] usb: misc: usbtest: add fix for driver hang Lu Baolu
2016-08-10 14:16 ` Alan Stern
2016-08-11 1:24 ` Lu Baolu [this message]
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=57ABD3B5.8020805@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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