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


Groups > linux.kernel > #1572363 > unrolled thread

[PATCH] usb: storage: fix infinite wait loop by incrementing loop counter

Started byColin King <colin.king@canonical.com>
First post2017-02-02 14:30 +0100
Last post2017-02-02 14:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] usb: storage: fix infinite wait loop by incrementing loop counter Colin King <colin.king@canonical.com> - 2017-02-02 14:30 +0100
    Re: [PATCH] usb: storage: fix infinite wait loop by incrementing  loop counter walter harms <wharms@bfs.de> - 2017-02-02 14:40 +0100

#1572363 — [PATCH] usb: storage: fix infinite wait loop by incrementing loop counter

FromColin King <colin.king@canonical.com>
Date2017-02-02 14:30 +0100
Subject[PATCH] usb: storage: fix infinite wait loop by incrementing loop counter
Message-ID<t6pCz-4Bc-41@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

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: <stable@vger.kernel.org>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 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));
-- 
2.10.2

[toc] | [next] | [standalone]


#1572366 — Re: [PATCH] usb: storage: fix infinite wait loop by incrementing loop counter

Fromwalter harms <wharms@bfs.de>
Date2017-02-02 14:40 +0100
SubjectRe: [PATCH] usb: storage: fix infinite wait loop by incrementing loop counter
Message-ID<t6pMe-4F2-15@gated-at.bofh.it>
In reply to#1572363

Am 02.02.2017 14:19, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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: <stable@vger.kernel.org>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web