Skip to content

Commit 22034ee

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: ftdi_sio: fix line-status over-reporting
commit a6bb1e17a39818b01b55d8e6238b4b5f06d55038 upstream. 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: 72fda3c ("USB: serial: ftd_sio: implement sysrq handling on break") Fixes: 166ceb6 ("USB: ftdi_sio: clean up line-status handling") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cfad081 commit 22034ee

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

drivers/usb/serial/ftdi_sio.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,20 @@ static int ftdi_process_packet(struct usb_serial_port *port,
20702070
priv->prev_status = status;
20712071
}
20722072

2073+
/* save if the transmitter is empty or not */
2074+
if (packet[1] & FTDI_RS_TEMT)
2075+
priv->transmit_empty = 1;
2076+
else
2077+
priv->transmit_empty = 0;
2078+
2079+
len -= 2;
2080+
if (!len)
2081+
return 0; /* status only */
2082+
2083+
/*
2084+
* Break and error status must only be processed for packets with
2085+
* data payload to avoid over-reporting.
2086+
*/
20732087
flag = TTY_NORMAL;
20742088
if (packet[1] & FTDI_RS_ERR_MASK) {
20752089
/* Break takes precedence over parity, which takes precedence
@@ -2092,15 +2106,6 @@ static int ftdi_process_packet(struct usb_serial_port *port,
20922106
}
20932107
}
20942108

2095-
/* save if the transmitter is empty or not */
2096-
if (packet[1] & FTDI_RS_TEMT)
2097-
priv->transmit_empty = 1;
2098-
else
2099-
priv->transmit_empty = 0;
2100-
2101-
len -= 2;
2102-
if (!len)
2103-
return 0; /* status only */
21042109
port->icount.rx += len;
21052110
ch = packet + 2;
21062111

0 commit comments

Comments
 (0)