[SRU X] [PATCH 5/5] tty: Simplify tty->count math in tty_reopen()
Guilherme G. Piccoli
gpiccoli at canonical.com
Tue Jan 8 20:18:49 UTC 2019
From: Dmitry Safonov <dima at arista.com>
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 at suse.com>
Link: lkml.kernel.org/r/<20180829022353.23568-2-dima at arista.com>
Suggested-by: Jiri Slaby <jslaby at suse.com>
Reviewed-by: Jiri Slaby <jslaby at suse.cz>
Tested-by: Mark Rutland <mark.rutland at arm.com>
Signed-off-by: Dmitry Safonov <dima at arista.com>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
(cherry-picked from cf62a1a13749db0d32b5cdd800ea91a4087319de upstream)
Signed-off-by: Guilherme G. Piccoli <gpiccoli at canonical.com>
---
drivers/tty/tty_io.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 3784f55f3dc9..a7511d5fad9e 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1490,16 +1490,13 @@ static int tty_reopen(struct tty_struct *tty)
if (retval)
return retval;
- tty->count++;
- if (tty->ldisc)
- goto out_unlock;
-
- retval = tty_ldisc_reinit(tty, tty->termios.c_line);
- if (retval)
- tty->count--;
-
-out_unlock:
+ if (!tty->ldisc)
+ retval = tty_ldisc_reinit(tty, tty->termios.c_line);
tty_ldisc_unlock(tty);
+
+ if (retval == 0)
+ tty->count++;
+
return retval;
}
--
2.19.2
More information about the kernel-team
mailing list