[PATCH] tty: fix NULL ptr dereference
From: Jiri Slaby
Date: Wed Aug 29 2018 - 09:49:51 EST
Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
---
drivers/tty/tty_io.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index f89939922050..160f320e0d2c 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1255,6 +1255,7 @@ static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *
static int tty_reopen(struct tty_struct *tty)
{
struct tty_driver *driver = tty->driver;
+ int ret = 0;
if (driver->type == TTY_DRIVER_TYPE_PTY &&
driver->subtype == PTY_TYPE_MASTER)
@@ -1268,10 +1269,12 @@ static int tty_reopen(struct tty_struct *tty)
tty->count++;
+ tty_ldisc_lock(tty, MAX_SCHEDULE_TIMEOUT);
if (!tty->ldisc)
- return tty_ldisc_reinit(tty, tty->termios.c_line);
+ ret = tty_ldisc_reinit(tty, tty->termios.c_line);
+ tty_ldisc_unlock(tty);
- return 0;
+ return ret;
}
/**
--
2.18.0
--------------60B1CCB6B678BE686DBE8098--