Skip to content

Commit 0005c0d

Browse files
oneukumDmitry Shmidt
authored and
Dmitry Shmidt
committed
usb: hub: fix a typo in hub_port_init() leading to wrong logic
commit 0d5ce77 upstream. A typo of j for i led to a logic bug. To rule out future confusion, the variable names are made meaningful. Signed-off-by: Oliver Neukum <ONeukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ef501a7 commit 0005c0d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/usb/core/hub.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -4277,7 +4277,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
42774277
{
42784278
struct usb_device *hdev = hub->hdev;
42794279
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
4280-
int i, j, retval;
4280+
int retries, operations, retval, i;
42814281
unsigned delay = HUB_SHORT_RESET_TIME;
42824282
enum usb_device_speed oldspeed = udev->speed;
42834283
const char *speed;
@@ -4379,7 +4379,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
43794379
* first 8 bytes of the device descriptor to get the ep0 maxpacket
43804380
* value.
43814381
*/
4382-
for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) {
4382+
for (retries = 0; retries < GET_DESCRIPTOR_TRIES; (++retries, msleep(100))) {
43834383
bool did_new_scheme = false;
43844384

43854385
if (use_new_scheme(udev, retry_counter)) {
@@ -4406,7 +4406,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
44064406
* 255 is for WUSB devices, we actually need to use
44074407
* 512 (WUSB1.0[4.8.1]).
44084408
*/
4409-
for (j = 0; j < 3; ++j) {
4409+
for (operations = 0; operations < 3; ++operations) {
44104410
buf->bMaxPacketSize0 = 0;
44114411
r = usb_control_msg(udev, usb_rcvaddr0pipe(),
44124412
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
@@ -4432,7 +4432,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
44324432
* reset. But only on the first attempt,
44334433
* lest we get into a time out/reset loop
44344434
*/
4435-
if (r == 0 || (r == -ETIMEDOUT && j == 0))
4435+
if (r == 0 || (r == -ETIMEDOUT && retries == 0))
44364436
break;
44374437
}
44384438
udev->descriptor.bMaxPacketSize0 =
@@ -4464,7 +4464,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
44644464
* authorization will assign the final address.
44654465
*/
44664466
if (udev->wusb == 0) {
4467-
for (j = 0; j < SET_ADDRESS_TRIES; ++j) {
4467+
for (operations = 0; operations < SET_ADDRESS_TRIES; ++operations) {
44684468
retval = hub_set_address(udev, devnum);
44694469
if (retval >= 0)
44704470
break;

0 commit comments

Comments
 (0)