Skip to content

Commit a6bb1e1

Browse files
committed
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 <[email protected]> Fixes: 72fda3c ("USB: serial: ftd_sio: implement sysrq handling on break") Fixes: 166ceb6 ("USB: ftdi_sio: clean up line-status handling") Cc: stable <[email protected]> # v2.6.35 Signed-off-by: Johan Hovold <[email protected]>
1 parent 9a59365 commit a6bb1e1

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

drivers/usb/serial/ftdi_sio.c

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

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+
*/
20712085
flag = TTY_NORMAL;
20722086
if (packet[1] & FTDI_RS_ERR_MASK) {
20732087
/* Break takes precedence over parity, which takes precedence
@@ -2090,15 +2104,6 @@ static int ftdi_process_packet(struct usb_serial_port *port,
20902104
}
20912105
}
20922106

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 */
21022107
port->icount.rx += len;
21032108
ch = packet + 2;
21042109

0 commit comments

Comments
 (0)