Commit bd91917a authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Kleber Sacilotto de Souza

tty: Simplify tty->count math in tty_reopen()

BugLink: https://bugs.launchpad.net/bugs/1791758

As notted by Jiri, tty_ldisc_reinit() shouldn't rely on tty counter.
Simplify math by increasing the counter after reinit success.

Cc: Jiri Slaby <jslaby@suse.com>
Link: lkml.kernel.org/r/<20180829022353.23568-2-dima@arista.com>
Suggested-by: default avatarJiri Slaby <jslaby@suse.com>
Reviewed-by: default avatarJiri Slaby <jslaby@suse.cz>
Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarDmitry Safonov <dima@arista.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit cf62a1a1)
Signed-off-by: default avatarGuilherme G. Piccoli <gpiccoli@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarKleber Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 1096e145
......@@ -1490,16 +1490,13 @@ static int tty_reopen(struct tty_struct *tty)
if (retval)
return retval;
tty->count++;
if (tty->ldisc)
goto out_unlock;
if (!tty->ldisc)
retval = tty_ldisc_reinit(tty, tty->termios.c_line);
tty_ldisc_unlock(tty);
retval = tty_ldisc_reinit(tty, tty->termios.c_line);
if (retval)
tty->count--;
if (retval == 0)
tty->count++;
out_unlock:
tty_ldisc_unlock(tty);
return retval;
}
......
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