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; - - 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; }