aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-02-02 11:38:35 -0500
committerJohan Hovold <johan@kernel.org>2017-02-06 12:29:06 -0500
commita6bb1e17a39818b01b55d8e6238b4b5f06d55038 (patch)
treee475d176db3be19bf1cbc6756b1b56b0cf754196
parent9a593656def0dc2f6c227851e8e602077267a5f1 (diff)
USB: serial: ftdi_sio: fix line-status over-reporting
FTDI devices use a receive latency timer to periodically empty the receive buffer and report modem and line status (also when the buffer is empty). When a break or error condition is detected the corresponding status flags will be set on a packet with nonzero data payload and the flags are not updated until the break is over or further characters are received. In order to avoid over-reporting break and error conditions, these flags must therefore only be processed for packets with payload. This specifically fixes the case where after an overrun, the error condition is continuously reported and NULL-characters inserted until further data is received. Reported-by: Michael Walle <michael@walle.cc> Fixes: 72fda3ca6fc1 ("USB: serial: ftd_sio: implement sysrq handling on break") Fixes: 166ceb690750 ("USB: ftdi_sio: clean up line-status handling") Cc: stable <stable@vger.kernel.org> # v2.6.35 Signed-off-by: Johan Hovold <johan@kernel.org>
-rw-r--r--drivers/usb/serial/ftdi_sio.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index e82dbb3d0883..c540de15aad2 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2068,6 +2068,20 @@ static int ftdi_process_packet(struct usb_serial_port *port,
2068 priv->prev_status = status; 2068 priv->prev_status = status;
2069 } 2069 }
2070 2070
2071 /* save if the transmitter is empty or not */
2072 if (packet[1] & FTDI_RS_TEMT)
2073 priv->transmit_empty = 1;
2074 else
2075 priv->transmit_empty = 0;
2076
2077 len -= 2;
2078 if (!len)
2079 return 0; /* status only */
2080
2081 /*
2082 * Break and error status must only be processed for packets with
2083 * data payload to avoid over-reporting.
2084 */
2071 flag = TTY_NORMAL; 2085 flag = TTY_NORMAL;
2072 if (packet[1] & FTDI_RS_ERR_MASK) { 2086 if (packet[1] & FTDI_RS_ERR_MASK) {
2073 /* Break takes precedence over parity, which takes precedence 2087 /* Break takes precedence over parity, which takes precedence
@@ -2090,15 +2104,6 @@ static int ftdi_process_packet(struct usb_serial_port *port,
2090 } 2104 }
2091 } 2105 }
2092 2106
2093 /* save if the transmitter is empty or not */
2094 if (packet[1] & FTDI_RS_TEMT)
2095 priv->transmit_empty = 1;
2096 else
2097 priv->transmit_empty = 0;
2098
2099 len -= 2;
2100 if (!len)
2101 return 0; /* status only */
2102 port->icount.rx += len; 2107 port->icount.rx += len;
2103 ch = packet + 2; 2108 ch = packet + 2;
2104 2109