mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
tty: Drop tty->count on tty_reopen() failure
In case of tty_ldisc_reinit() failure, tty->count should be decremented
back, otherwise we will never release_tty().
Tetsuo reported that it fixes noisy warnings on tty release like:
pts pts4033: tty_release: tty->count(10529) != (#fd's(7) + #kopen's(0))
Fixes: commit 892d1fa7ea ("tty: Destroy ldisc instance on hangup")
Cc: [email protected] # v4.6+
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jiri Slaby <[email protected]>
Reviewed-by: Jiri Slaby <[email protected]>
Tested-by: Jiri Slaby <[email protected]>
Tested-by: Mark Rutland <[email protected]>
Tested-by: Tetsuo Handa <[email protected]>
Signed-off-by: Dmitry Safonov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
be28c1e3ca
commit
fe32416790
1 changed files with 8 additions and 3 deletions
|
|
@ -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 retval;
|
||||
|
||||
if (driver->type == TTY_DRIVER_TYPE_PTY &&
|
||||
driver->subtype == PTY_TYPE_MASTER)
|
||||
|
|
@ -1268,10 +1269,14 @@ static int tty_reopen(struct tty_struct *tty)
|
|||
|
||||
tty->count++;
|
||||
|
||||
if (!tty->ldisc)
|
||||
return tty_ldisc_reinit(tty, tty->termios.c_line);
|
||||
if (tty->ldisc)
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
retval = tty_ldisc_reinit(tty, tty->termios.c_line);
|
||||
if (retval)
|
||||
tty->count--;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue