mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-03 17:14:14 +08:00
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>
This commit is contained in:
parent
c96cf923a9
commit
cf62a1a137
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user