提交 e33eab9d 编写于 作者: D Dan Carpenter 提交者: Johan Hovold

USB: serial: ch341: fix type promotion bug in ch341_control_in()

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: 2d5a9c72 ("USB: serial: ch341: fix control-message error handling")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: NJohan Hovold <johan@kernel.org>
上级 021c9179
...@@ -128,7 +128,7 @@ static int ch341_control_in(struct usb_device *dev, ...@@ -128,7 +128,7 @@ static int ch341_control_in(struct usb_device *dev,
r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
value, index, buf, bufsize, DEFAULT_TIMEOUT); value, index, buf, bufsize, DEFAULT_TIMEOUT);
if (r < bufsize) { if (r < (int)bufsize) {
if (r >= 0) { if (r >= 0) {
dev_err(&dev->dev, dev_err(&dev->dev,
"short control message received (%d < %u)\n", "short control message received (%d < %u)\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册