Skip to content

Commit 0d1b459

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: mos7720: fix control-message error handling
[ Upstream commit 0d130367abf582e7cbf60075c2a7ab53817b1d14 ] Make sure to log an error on short transfers when reading a device register. Also clear the provided buffer (which if often an uninitialised automatic variable) on errors as the driver currently does not bother to check for errors. Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8b2522e commit 0d1b459

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/usb/serial/mos7720.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,16 @@ static int read_mos_reg(struct usb_serial *serial, unsigned int serial_portnum,
234234

235235
status = usb_control_msg(usbdev, pipe, request, requesttype, value,
236236
index, buf, 1, MOS_WDR_TIMEOUT);
237-
if (status == 1)
237+
if (status == 1) {
238238
*data = *buf;
239-
else if (status < 0)
239+
} else {
240240
dev_err(&usbdev->dev,
241241
"mos7720: usb_control_msg() failed: %d\n", status);
242+
if (status >= 0)
243+
status = -EIO;
244+
*data = 0;
245+
}
246+
242247
kfree(buf);
243248

244249
return status;

0 commit comments

Comments
 (0)