From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx02-sz.bfs.de ([194.94.69.103]:5584 "EHLO mx02-sz.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750837AbdBBNbv (ORCPT ); Thu, 2 Feb 2017 08:31:51 -0500 Message-ID: <589334C1.7020802@bfs.de> Date: Thu, 02 Feb 2017 14:31:45 +0100 From: walter harms Reply-To: wharms@bfs.de MIME-Version: 1.0 To: Colin King CC: Alan Stern , Greg Kroah-Hartman , linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] usb: storage: fix infinite wait loop by incrementing loop counter References: <20170202131910.31001-1-colin.king@canonical.com> In-Reply-To: <20170202131910.31001-1-colin.king@canonical.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: Am 02.02.2017 14:19, schrieb Colin King: > From: Colin Ian King > > If jumpshot_get_status continues to return a failed result then the > wait loop will spin forever because the waitcount counter is never > being incremented and we don't ever timeout. Fix this by incrementing > waitcount. > > Cc: > Signed-off-by: Colin Ian King > --- > drivers/usb/storage/jumpshot.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c > index 011e527..81d82ce 100644 > --- a/drivers/usb/storage/jumpshot.c > +++ b/drivers/usb/storage/jumpshot.c > @@ -311,6 +311,7 @@ static int jumpshot_write_data(struct us_data *us, > if (result != USB_STOR_TRANSPORT_GOOD) { > // I have not experimented to find the smallest value. > // > + waitcount++; > msleep(50); > } > } while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 10)); the function looks a bit complicated .. what i about this ? for(waitcount=0;waitcount<10;waitcount++) { result = jumpshot_get_status(us); if ( result == USB_STOR_TRANSPORT_GOOD) break; msleep(50); } just my 2 cents, re, wg