Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: hub: fix a typo in hub_port_init() leading to wrong logic

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>
CC: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Oliver Neukum and committed by
Greg Kroah-Hartman
0d5ce778 ff075d67

+5 -5
+5 -5
drivers/usb/core/hub.c
··· 4344 4344 { 4345 4345 struct usb_device *hdev = hub->hdev; 4346 4346 struct usb_hcd *hcd = bus_to_hcd(hdev->bus); 4347 - int i, j, retval; 4347 + int retries, operations, retval, i; 4348 4348 unsigned delay = HUB_SHORT_RESET_TIME; 4349 4349 enum usb_device_speed oldspeed = udev->speed; 4350 4350 const char *speed; ··· 4449 4449 * first 8 bytes of the device descriptor to get the ep0 maxpacket 4450 4450 * value. 4451 4451 */ 4452 - for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) { 4452 + for (retries = 0; retries < GET_DESCRIPTOR_TRIES; (++retries, msleep(100))) { 4453 4453 bool did_new_scheme = false; 4454 4454 4455 4455 if (use_new_scheme(udev, retry_counter)) { ··· 4476 4476 * 255 is for WUSB devices, we actually need to use 4477 4477 * 512 (WUSB1.0[4.8.1]). 4478 4478 */ 4479 - for (j = 0; j < 3; ++j) { 4479 + for (operations = 0; operations < 3; ++operations) { 4480 4480 buf->bMaxPacketSize0 = 0; 4481 4481 r = usb_control_msg(udev, usb_rcvaddr0pipe(), 4482 4482 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, ··· 4502 4502 * reset. But only on the first attempt, 4503 4503 * lest we get into a time out/reset loop 4504 4504 */ 4505 - if (r == 0 || (r == -ETIMEDOUT && j == 0)) 4505 + if (r == 0 || (r == -ETIMEDOUT && retries == 0)) 4506 4506 break; 4507 4507 } 4508 4508 udev->descriptor.bMaxPacketSize0 = ··· 4534 4534 * authorization will assign the final address. 4535 4535 */ 4536 4536 if (udev->wusb == 0) { 4537 - for (j = 0; j < SET_ADDRESS_TRIES; ++j) { 4537 + for (operations = 0; operations < SET_ADDRESS_TRIES; ++operations) { 4538 4538 retval = hub_set_address(udev, devnum); 4539 4539 if (retval >= 0) 4540 4540 break;