]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.28/usb-serial-mct_u232-fix-modem-status-error-handling.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.9.28 / usb-serial-mct_u232-fix-modem-status-error-handling.patch
1 From 36356a669eddb32917fc4b5c2b9b8bf80ede69de Mon Sep 17 00:00:00 2001
2 From: Johan Hovold <johan@kernel.org>
3 Date: Thu, 12 Jan 2017 14:56:16 +0100
4 Subject: USB: serial: mct_u232: fix modem-status error handling
5
6 From: Johan Hovold <johan@kernel.org>
7
8 commit 36356a669eddb32917fc4b5c2b9b8bf80ede69de upstream.
9
10 Make sure to detect short control-message transfers so that errors are
11 logged when reading the modem status at open.
12
13 Note that while this also avoids initialising the modem status using
14 uninitialised heap data, these bits could not leak to user space as they
15 are currently not used.
16
17 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
18 Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 Signed-off-by: Johan Hovold <johan@kernel.org>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22 ---
23 drivers/usb/serial/mct_u232.c | 6 +++++-
24 1 file changed, 5 insertions(+), 1 deletion(-)
25
26 --- a/drivers/usb/serial/mct_u232.c
27 +++ b/drivers/usb/serial/mct_u232.c
28 @@ -322,8 +322,12 @@ static int mct_u232_get_modem_stat(struc
29 MCT_U232_GET_REQUEST_TYPE,
30 0, 0, buf, MCT_U232_GET_MODEM_STAT_SIZE,
31 WDR_TIMEOUT);
32 - if (rc < 0) {
33 + if (rc < MCT_U232_GET_MODEM_STAT_SIZE) {
34 dev_err(&port->dev, "Get MODEM STATus failed (error = %d)\n", rc);
35 +
36 + if (rc >= 0)
37 + rc = -EIO;
38 +
39 *msr = 0;
40 } else {
41 *msr = buf[0];