Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 171f90d4 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Greg Kroah-Hartman
Browse files

tty: Drop tty->count on tty_reopen() failure



commit fe32416790093b31364c08395727de17ec96ace1 upstream.

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 892d1fa7 ("tty: Destroy ldisc instance on hangup")

Cc: stable@vger.kernel.org # v4.6+
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Reviewed-by: default avatarJiri Slaby <jslaby@suse.cz>
Tested-by: default avatarJiri Slaby <jslaby@suse.com>
Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
Tested-by: default avatarTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: default avatarDmitry Safonov <dima@arista.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c92e73b1
Loading
Loading
Loading
Loading
+8 −3
Original line number Original line Diff line number Diff line
@@ -1254,6 +1254,7 @@ static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *
static int tty_reopen(struct tty_struct *tty)
static int tty_reopen(struct tty_struct *tty)
{
{
	struct tty_driver *driver = tty->driver;
	struct tty_driver *driver = tty->driver;
	int retval;


	if (driver->type == TTY_DRIVER_TYPE_PTY &&
	if (driver->type == TTY_DRIVER_TYPE_PTY &&
	    driver->subtype == PTY_TYPE_MASTER)
	    driver->subtype == PTY_TYPE_MASTER)
@@ -1267,10 +1268,14 @@ static int tty_reopen(struct tty_struct *tty)


	tty->count++;
	tty->count++;


	if (!tty->ldisc)
	if (tty->ldisc)
		return tty_ldisc_reinit(tty, tty->termios.c_line);

		return 0;
		return 0;

	retval = tty_ldisc_reinit(tty, tty->termios.c_line);
	if (retval)
		tty->count--;

	return retval;
}
}


/**
/**