diff options
| author | Dmitry Safonov <dima@arista.com> | 2018-09-17 19:52:52 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-18 09:42:24 -0400 |
| commit | fe32416790093b31364c08395727de17ec96ace1 (patch) | |
| tree | 760bb7b980b486ab93baca770b23de6df8818500 /drivers | |
| parent | be28c1e3ca29887e207f0cbcd294cefe5074bab6 (diff) | |
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 892d1fa7eaae ("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: Jiri Slaby <jslaby@suse.cz>
Tested-by: Jiri Slaby <jslaby@suse.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/tty/tty_io.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 32bc3e3fe4d3..5e5da9acaf0a 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 * | |||
| 1255 | static int tty_reopen(struct tty_struct *tty) | 1255 | static int tty_reopen(struct tty_struct *tty) |
| 1256 | { | 1256 | { |
| 1257 | struct tty_driver *driver = tty->driver; | 1257 | struct tty_driver *driver = tty->driver; |
| 1258 | int retval; | ||
| 1258 | 1259 | ||
| 1259 | if (driver->type == TTY_DRIVER_TYPE_PTY && | 1260 | if (driver->type == TTY_DRIVER_TYPE_PTY && |
| 1260 | driver->subtype == PTY_TYPE_MASTER) | 1261 | driver->subtype == PTY_TYPE_MASTER) |
| @@ -1268,10 +1269,14 @@ static int tty_reopen(struct tty_struct *tty) | |||
| 1268 | 1269 | ||
| 1269 | tty->count++; | 1270 | tty->count++; |
| 1270 | 1271 | ||
| 1271 | if (!tty->ldisc) | 1272 | if (tty->ldisc) |
| 1272 | return tty_ldisc_reinit(tty, tty->termios.c_line); | 1273 | return 0; |
| 1273 | 1274 | ||
| 1274 | return 0; | 1275 | retval = tty_ldisc_reinit(tty, tty->termios.c_line); |
| 1276 | if (retval) | ||
| 1277 | tty->count--; | ||
| 1278 | |||
| 1279 | return retval; | ||
| 1275 | } | 1280 | } |
| 1276 | 1281 | ||
| 1277 | /** | 1282 | /** |
