[PATCH 3.16 039/328] tty: fix termios input-speed encoding

From: Ben Hutchings
Date: Sun Dec 09 2018 - 17:13:02 EST

3.16.62-rc1 review patch. If anyone has any objections, please let me know.


From: Johan Hovold <johan@xxxxxxxxxx>

commit fada18c48d774b9e837928ecdce6a5d5fdd11ee7 upstream.

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 <johan@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
[bwh: Backported to 3.16: adjust filename]
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
drivers/tty/tty_ioctl.c | 3 +++
1 file changed, 3 insertions(+)

--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -419,6 +419,9 @@ void tty_termios_encode_baud_rate(struct
ibinput = 1; /* An input speed was specified */
termios->c_cflag &= ~CBAUD;
+#ifdef IBSHIFT
+ termios->c_cflag &= ~(CBAUD << IBSHIFT);

* Our goal is to find a close match to the standard baud rate