usb: Fix usb_control_msg() error path
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)
Signed-off-by Philip Oberfichtner <[email protected]>
[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
@@ -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
Quoted 19 lines · Philip Oberfichtner
As pointed out in [1], there is a logic error in the
-ETIMEDOUTreturn 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)Signed-off-by Philip Oberfichtner <[email protected]>[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
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)
Reviewed-by Andrew Goodbody <[email protected]>