Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1581054
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | usb: storage: suspicious code |
| Date | 2017-02-15 06:10 +0100 |
| Message-ID | <tb00N-3Ky-1@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
Hello,
I ran into the following piece of code at drivers/usb/storage/jumpshot.c:305 (linux-next), and it seems a little bit suspicious:
// read the result. apparently the bulk write can complete
// before the jumpshot drive is finished writing. so we loop
// here until we get a good return code
waitcount = 0;
do {
result = jumpshot_get_status(us);
if (result != USB_STOR_TRANSPORT_GOOD) {
// I have not experimented to find the smallest value.
//
msleep(50);
}
} while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 10));
if (result != USB_STOR_TRANSPORT_GOOD)
usb_stor_dbg(us, "Gah! Waitcount = 10. Bad write!?\n");
Variable 'waitcount' is never updated inside the do-while loop. So, either it isn't needed at all or line 316 should be modified (++waitcount < 10)
In case 'waitcount' isn't needed, lines 318 and 319 should be removed.
Can someone help me to clarify this so I can write a patch to fix this code?
Thank you
--
Gustavo A. R. Silva
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
usb: storage: suspicious code "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-02-15 06:10 +0100
Re: [usb-storage] usb: storage: suspicious code Oliver Neukum <oneukum@suse.com> - 2017-02-15 08:10 +0100
Re: [usb-storage] usb: storage: suspicious code "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-02-15 08:50 +0100
[PATCH] usb: storage: add missing pre-increment to variable "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-02-15 09:10 +0100
Re: [usb-storage] [PATCH] usb: storage: add missing pre-increment to variable Alan Stern <stern@rowland.harvard.edu> - 2017-02-15 16:30 +0100
Re: [usb-storage] [PATCH] usb: storage: add missing pre-increment to variable "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-02-21 00:40 +0100
csiph-web