[PATCH] usb: misc: usbio: Handle negative error code from usb_control_msg()
From: Serhat Kumral
Date: Sat Oct 03 2026 - 10:29:53 EST
The sizeof(*cpkt) is unsigned, so comparing "ret < sizeof(*cpkt)" promotes
"ret" to unsigned and negative error codes from usb_control_msg() are
not caught. Cast the sizeof to int so the error handling works.
Fixes: 121a0f839dbb ("usb: misc: Add Intel USBIO bridge driver")
Assisted-by: LLM
Signed-off-by: Serhat Kumral <serhatkumral1@xxxxxxxxx>
---
found by smatch:
- drivers/usb/misc/usbio.c:187 usbio_ctrl_msg() warn: error code type promoted to positive: 'ret'
drivers/usb/misc/usbio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/misc/usbio.c b/drivers/usb/misc/usbio.c
index fe093e7760d5..3f73f7c3d68a 100644
--- a/drivers/usb/misc/usbio.c
+++ b/drivers/usb/misc/usbio.c
@@ -184,7 +184,7 @@ static int usbio_ctrl_msg(struct usbio_device *usbio, u8 type, u8 cmd,
dev_dbg(usbio->dev, "control in %d hdr %*phN data %*phN\n", ret,
(int)sizeof(*cpkt), cpkt, (int)cpkt->len, cpkt->data);
- if (ret < sizeof(*cpkt)) {
+ if (ret < (int)sizeof(*cpkt)) {
dev_err(usbio->dev, "USB control in failed: %d\n", ret);
return (ret < 0) ? ret : -EPROTO;
}
--
2.53.0