Skip to content

Commit 67f47e5

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: ark3116: fix register-accessor error handling
commit 9fef37d7cf170522fb354d6d0ea6de09b9b16678 upstream. The current implementation failed to detect short transfers, something which could lead to bits of the uninitialised heap transfer buffer leaking to user space. Fixes: 149fc79 ("USB: ark3116: Setup some basic infrastructure for new ark3116 driver.") Fixes: f4c1e8d ("USB: ark3116: Make existing functions 16450-aware and add close and release functions.") Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b04a2ca commit 67f47e5

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/usb/serial/ark3116.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,17 @@ static int ark3116_read_reg(struct usb_serial *serial,
9999
usb_rcvctrlpipe(serial->dev, 0),
100100
0xfe, 0xc0, 0, reg,
101101
buf, 1, ARK_TIMEOUT);
102-
if (result < 0)
102+
if (result < 1) {
103+
dev_err(&serial->interface->dev,
104+
"failed to read register %u: %d\n",
105+
reg, result);
106+
if (result >= 0)
107+
result = -EIO;
108+
103109
return result;
104-
else
105-
return buf[0];
110+
}
111+
112+
return buf[0];
106113
}
107114

108115
static inline int calc_divisor(int bps)

0 commit comments

Comments
 (0)