From: Johan Hovold <jo...@kernel.org>

[ Upstream commit fada18c48d774b9e837928ecdce6a5d5fdd11ee7 ]

Make sure to clear the CIBAUD bits before OR-ing the new mask when
encoding the termios input baud rate.

This could otherwise lead to an incorrect input rate being reported back
and incidentally set on subsequent termios updates.

Fixes: edc6afc54968 ("[PATCH] tty: switch to ktermios and new framework")
Signed-off-by: Johan Hovold <jo...@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.le...@microsoft.com>
---
 drivers/tty/tty_baudrate.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c
index d39b4f18e0d9..3e827a3d48d5 100644
--- a/drivers/tty/tty_baudrate.c
+++ b/drivers/tty/tty_baudrate.c
@@ -173,6 +173,9 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
                iclose = 0;
 #endif
        termios->c_cflag &= ~CBAUD;
+#ifdef IBSHIFT
+       termios->c_cflag &= ~(CBAUD << IBSHIFT);
+#endif
 
        /*
         *      Our goal is to find a close match to the standard baud rate
-- 
2.17.1

Reply via email to