diff options
author | Dmitry Safonov <dima@arista.com> | 2018-11-01 03:24:49 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-12-05 14:16:33 +0300 |
commit | cf62a1a13749db0d32b5cdd800ea91a4087319de (patch) | |
tree | 6e0b9353bf06d6e167bd9fcff0da3eb00605182d /drivers/tty | |
parent | c96cf923a98d1b094df9f0cf97a83e118817e31b (diff) | |
download | linux-cf62a1a13749db0d32b5cdd800ea91a4087319de.tar.xz |
tty: Simplify tty->count math in tty_reopen()
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: Jiri Slaby <jslaby@suse.com>
Reviewed-by: Jiri Slaby <jslaby@suse.cz>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/tty_io.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index f73d8fa7f02b..57d06eda5b2f 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1272,16 +1272,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; } |