mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-12 04:15:21 +02:00
tty: n_tty: Fix buffer offsets when lookahead is used
commitb19ab7ee2c
upstream. When lookahead has "consumed" some characters (la_count > 0), n_tty_receive_buf_standard() and n_tty_receive_buf_closing() for characters beyond the la_count are given wrong cp/fp offsets which leads to duplicating and losing some characters. If la_count > 0, correct buffer pointers and make count consistent too (the latter is not strictly necessary to fix the issue but seems more logical to adjust all variables immediately to keep state consistent). Reported-by: Vadym Krevs <vkrevs@yahoo.com> Fixes:6bb6fa6908
("tty: Implement lookahead to process XON/XOFF timely") Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218834 Tested-by: Vadym Krevs <vkrevs@yahoo.com> Cc: stable@vger.kernel.org Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240514140429.12087-1-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ce356d8d7e
commit
b895a1b981
|
@ -1624,15 +1624,25 @@ static void __receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp,
|
||||||
else if (ldata->raw || (L_EXTPROC(tty) && !preops))
|
else if (ldata->raw || (L_EXTPROC(tty) && !preops))
|
||||||
n_tty_receive_buf_raw(tty, cp, fp, count);
|
n_tty_receive_buf_raw(tty, cp, fp, count);
|
||||||
else if (tty->closing && !L_EXTPROC(tty)) {
|
else if (tty->closing && !L_EXTPROC(tty)) {
|
||||||
if (la_count > 0)
|
if (la_count > 0) {
|
||||||
n_tty_receive_buf_closing(tty, cp, fp, la_count, true);
|
n_tty_receive_buf_closing(tty, cp, fp, la_count, true);
|
||||||
if (count > la_count)
|
cp += la_count;
|
||||||
n_tty_receive_buf_closing(tty, cp, fp, count - la_count, false);
|
if (fp)
|
||||||
|
fp += la_count;
|
||||||
|
count -= la_count;
|
||||||
|
}
|
||||||
|
if (count > 0)
|
||||||
|
n_tty_receive_buf_closing(tty, cp, fp, count, false);
|
||||||
} else {
|
} else {
|
||||||
if (la_count > 0)
|
if (la_count > 0) {
|
||||||
n_tty_receive_buf_standard(tty, cp, fp, la_count, true);
|
n_tty_receive_buf_standard(tty, cp, fp, la_count, true);
|
||||||
if (count > la_count)
|
cp += la_count;
|
||||||
n_tty_receive_buf_standard(tty, cp, fp, count - la_count, false);
|
if (fp)
|
||||||
|
fp += la_count;
|
||||||
|
count -= la_count;
|
||||||
|
}
|
||||||
|
if (count > 0)
|
||||||
|
n_tty_receive_buf_standard(tty, cp, fp, count, false);
|
||||||
|
|
||||||
flush_echoes(tty);
|
flush_echoes(tty);
|
||||||
if (tty->ops->flush_chars)
|
if (tty->ops->flush_chars)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user