]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.28/usb-serial-ark3116-fix-open-error-handling.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.28 / usb-serial-ark3116-fix-open-error-handling.patch
1 From b631433b175f1002a31020e09bbfc2e5caecf290 Mon Sep 17 00:00:00 2001
2 From: Johan Hovold <johan@kernel.org>
3 Date: Thu, 12 Jan 2017 14:56:10 +0100
4 Subject: USB: serial: ark3116: fix open error handling
5
6 From: Johan Hovold <johan@kernel.org>
7
8 commit b631433b175f1002a31020e09bbfc2e5caecf290 upstream.
9
10 Fix open error handling which failed to detect errors when reading the
11 MSR and LSR registers, something which could lead to the shadow
12 registers being initialised from errnos.
13
14 Note that calling the generic close implementation is sufficient in the
15 error paths as the interrupt urb has not yet been submitted and the
16 register updates have not been made.
17
18 Fixes: f4c1e8d597d1 ("USB: ark3116: Make existing functions 16450-aware
19 and add close and release functions.")
20 Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21 Signed-off-by: Johan Hovold <johan@kernel.org>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24 ---
25 drivers/usb/serial/ark3116.c | 25 +++++++++++++++++++------
26 1 file changed, 19 insertions(+), 6 deletions(-)
27
28 --- a/drivers/usb/serial/ark3116.c
29 +++ b/drivers/usb/serial/ark3116.c
30 @@ -373,23 +373,29 @@ static int ark3116_open(struct tty_struc
31 dev_dbg(&port->dev,
32 "%s - usb_serial_generic_open failed: %d\n",
33 __func__, result);
34 - goto err_out;
35 + goto err_free;
36 }
37
38 /* remove any data still left: also clears error state */
39 ark3116_read_reg(serial, UART_RX, buf);
40
41 /* read modem status */
42 - priv->msr = ark3116_read_reg(serial, UART_MSR, buf);
43 + result = ark3116_read_reg(serial, UART_MSR, buf);
44 + if (result < 0)
45 + goto err_close;
46 + priv->msr = *buf;
47 +
48 /* read line status */
49 - priv->lsr = ark3116_read_reg(serial, UART_LSR, buf);
50 + result = ark3116_read_reg(serial, UART_LSR, buf);
51 + if (result < 0)
52 + goto err_close;
53 + priv->lsr = *buf;
54
55 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
56 if (result) {
57 dev_err(&port->dev, "submit irq_in urb failed %d\n",
58 result);
59 - ark3116_close(port);
60 - goto err_out;
61 + goto err_close;
62 }
63
64 /* activate interrupts */
65 @@ -402,8 +408,15 @@ static int ark3116_open(struct tty_struc
66 if (tty)
67 ark3116_set_termios(tty, port, NULL);
68
69 -err_out:
70 kfree(buf);
71 +
72 + return 0;
73 +
74 +err_close:
75 + usb_serial_generic_close(port);
76 +err_free:
77 + kfree(buf);
78 +
79 return result;
80 }
81