Skip to contentSkip to conversation

usb: Fix usb_control_msg() error path

PATCH In review Philip Oberfichtner 2 participants 2 messages Jul 7, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: Fix usb_control_msg() error path

As pointed out in [1], there is a logic error in the -ETIMEDOUT return path.

The while() condition evaluates false, when timeout is 0. Postfix decrement makes it -1. Adapt the if statement accordingly.

Fixes 2fc8638403c (usb: Assimilate usb_get_descriptor() to linux)

[1] https://lore.kernel.org/u-boot/[email protected]/

---
 common/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/usb.c +1 -1
index 7a8435296c6..266339e4897 100644
@@ -258,7 +258,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
 		mdelay(1);
 	}
 
-	if (timeout == 0)
+	if (timeout == -1)
 		return -ETIMEDOUT;
 
 	if (dev->status)
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Philip Oberfichtner

As pointed out in [1], there is a logic error in the -ETIMEDOUT return path.

The while() condition evaluates false, when timeout is 0. Postfix decrement makes it -1. Adapt the if statement accordingly.

Fixes 2fc8638403c (usb: Assimilate usb_get_descriptor() to linux)

[1] https://lore.kernel.org/u-boot/[email protected]/

---
  common/usb.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
common/usb.c +0 -0
index 7a8435296c6..266339e4897 100644

common/usb.c int usb_control_msg(struct usb_device *dev, unsigned int pipe, · line 264

Quoted 8 lines
common/usb.c +1 -1
@@ -258,7 +258,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
  		mdelay(1);
  	}
 
-	if (timeout == 0)
+	if (timeout == -1)
  		return -ETIMEDOUT;
 
  	if (dev->status)