public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* usb: storage: suspicious code
@ 2017-02-15  5:06 Gustavo A. R. Silva
  2017-02-15  7:01 ` [usb-storage] " Oliver Neukum
  0 siblings, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2017-02-15  5:06 UTC (permalink / raw)
  To: stern, gregkh
  Cc: linux-usb, usb-storage, linux-kernel, Peter Senna Tschudi,
	Gustavo A. R. Silva

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-02-20 23:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-15  5:06 usb: storage: suspicious code Gustavo A. R. Silva
2017-02-15  7:01 ` [usb-storage] " Oliver Neukum
2017-02-15  7:14   ` Gustavo A. R. Silva
2017-02-15  7:39     ` [PATCH] usb: storage: add missing pre-increment to variable Gustavo A. R. Silva
2017-02-15 15:26       ` [usb-storage] " Alan Stern
2017-02-20 23:07         ` Gustavo A. R. Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox