n_tty: Fix throttle for canon lines > 3967 chars
authorPeter Hurley <peter@hurleysoftware.com>
Fri, 16 Jan 2015 20:05:35 +0000 (15:05 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Feb 2015 18:11:26 +0000 (10:11 -0800)
The tty driver will be mistakenly throttled if a line termination
has not been received, and the line exceeds 3967 chars. Thus, it is
possible for the driver to stop sending when it has not yet sent
the newline. This does not apply to the pty driver.

Don't throttle until at least one line termination has been
received.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_tty.c

index b60b043f47d89f0ed25e6471fa7b6013162b7a07..d4b14c30794e2ec78c6f83c57376a17f4e4fdda7 100644 (file)
@@ -247,6 +247,8 @@ static void n_tty_write_wakeup(struct tty_struct *tty)
 
 static void n_tty_check_throttle(struct tty_struct *tty)
 {
+       struct n_tty_data *ldata = tty->disc_data;
+
        if (tty->driver->type == TTY_DRIVER_TYPE_PTY)
                return;
        /*
@@ -254,6 +256,9 @@ static void n_tty_check_throttle(struct tty_struct *tty)
         * mode.  We don't want to throttle the driver if we're in
         * canonical mode and don't have a newline yet!
         */
+       if (ldata->icanon && ldata->canon_head == ldata->read_tail)
+               return;
+
        while (1) {
                int throttled;
                tty_set_flow_change(tty, TTY_THROTTLE_SAFE);