From: Dan Carpenter Date: Wed, 4 Jul 2018 09:29:38 +0000 (+0300) Subject: USB: serial: ch341: fix type promotion bug in ch341_control_in() X-Git-Tag: v4.9.113~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c73f193b320d8463c280ef8b4df314fb291f76b;p=platform%2Fkernel%2Flinux-amlogic.git USB: serial: ch341: fix type promotion bug in ch341_control_in() commit e33eab9ded328ccc14308afa51b5be7cbe78d30b upstream. The "r" variable is an int and "bufsize" is an unsigned int so the comparison is type promoted to unsigned. If usb_control_msg() returns a negative that is treated as a high positive value and the error handling doesn't work. Fixes: 2d5a9c72d0c4 ("USB: serial: ch341: fix control-message error handling") Signed-off-by: Dan Carpenter Cc: stable Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index e98590a..9a2c0c7 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -118,7 +118,7 @@ static int ch341_control_in(struct usb_device *dev, r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, value, index, buf, bufsize, DEFAULT_TIMEOUT); - if (r < bufsize) { + if (r < (int)bufsize) { if (r >= 0) { dev_err(&dev->dev, "short control message received (%d < %u)\n",