Commit 779c8f4d authored by Johan Hovold's avatar Johan Hovold Committed by Ben Hutchings

USB: serial: ftdi_sio: fix line-status over-reporting

commit a6bb1e17 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: default avatarMichael Walle <michael@walle.cc>
Fixes: 72fda3ca ("USB: serial: ftd_sio: implement sysrq handling on
break")
Fixes: 166ceb69 ("USB: ftdi_sio: clean up line-status handling")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 8d70ad1c
......@@ -2187,6 +2187,20 @@ static int ftdi_process_packet(struct tty_struct *tty,
priv->prev_status = status;
}
/* save if the transmitter is empty or not */
if (packet[1] & FTDI_RS_TEMT)
priv->transmit_empty = 1;
else
priv->transmit_empty = 0;
len -= 2;
if (!len)
return 0; /* status only */
/*
* Break and error status must only be processed for packets with
* data payload to avoid over-reporting.
*/
flag = TTY_NORMAL;
if (packet[1] & FTDI_RS_ERR_MASK) {
/* Break takes precedence over parity, which takes precedence
......@@ -2209,15 +2223,6 @@ static int ftdi_process_packet(struct tty_struct *tty,
}
}
/* save if the transmitter is empty or not */
if (packet[1] & FTDI_RS_TEMT)
priv->transmit_empty = 1;
else
priv->transmit_empty = 0;
len -= 2;
if (!len)
return 0; /* status only */
priv->icount.rx += len;
ch = packet + 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment