Skip to content

Commit

Permalink
USB: serial: ark3116: fix register-accessor error handling
Browse files Browse the repository at this point in the history
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.")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
  • Loading branch information
Johan Hovold committed Jan 16, 2017
1 parent 2c85e0a commit 9fef37d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/usb/serial/ark3116.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,17 @@ static int ark3116_read_reg(struct usb_serial *serial,
usb_rcvctrlpipe(serial->dev, 0),
0xfe, 0xc0, 0, reg,
buf, 1, ARK_TIMEOUT);
if (result < 0)
if (result < 1) {
dev_err(&serial->interface->dev,
"failed to read register %u: %d\n",
reg, result);
if (result >= 0)
result = -EIO;

return result;
else
return buf[0];
}

return buf[0];
}

static inline int calc_divisor(int bps)
Expand Down

0 comments on commit 9fef37d

Please sign in to comment.