[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190121122456.156487880@linuxfoundation.org>
Date: Mon, 21 Jan 2019 14:41:57 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Jiri Slaby <jslaby@...e.com>,
Jiri Slaby <jslaby@...e.cz>,
Mark Rutland <mark.rutland@....com>,
Dmitry Safonov <dima@...sta.com>
Subject: [PATCH 4.20 003/111] tty: Simplify tty->count math in tty_reopen()
4.20-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Safonov <dima@...sta.com>
commit cf62a1a13749db0d32b5cdd800ea91a4087319de upstream.
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@...e.com>
Link: lkml.kernel.org/r/<20180829022353.23568-2-dima@...sta.com>
Suggested-by: Jiri Slaby <jslaby@...e.com>
Reviewed-by: Jiri Slaby <jslaby@...e.cz>
Tested-by: Mark Rutland <mark.rutland@....com>
Signed-off-by: Dmitry Safonov <dima@...sta.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
drivers/tty/tty_io.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1272,16 +1272,13 @@ static int tty_reopen(struct tty_struct
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;
}
Powered by blists - more mailing lists