diff options
author | 2013-09-18 20:42:39 -0400 | |
---|---|---|
committer | 2013-09-25 18:08:34 -0700 | |
commit | e3bfea23a62dccfd12875a6cc24fa5c77e8a3c07 (patch) | |
tree | 004e21ee4cc60fc6a9dd9b57991dd968047fc0f8 /drivers/tty | |
parent | n_tty: Style fix in n_tty_set_termios (diff) | |
download | linux-e3bfea23a62dccfd12875a6cc24fa5c77e8a3c07.tar.gz linux-e3bfea23a62dccfd12875a6cc24fa5c77e8a3c07.tar.bz2 linux-e3bfea23a62dccfd12875a6cc24fa5c77e8a3c07.zip |
tty: Prevent tty_port destruction if tty not released
If the tty driver mistakenly drops the last port reference
before the tty has been released, issue a diagnostic and
abort the port destruction.
This will leak memory and may zombify the port, but might
otherwise keep the machine in runnable state.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/tty_port.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index f597e88a705d..7efbca474689 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c @@ -140,6 +140,10 @@ EXPORT_SYMBOL(tty_port_destroy); static void tty_port_destructor(struct kref *kref) { struct tty_port *port = container_of(kref, struct tty_port, kref); + + /* check if last port ref was dropped before tty release */ + if (WARN_ON(port->itty)) + return; if (port->xmit_buf) free_page((unsigned long)port->xmit_buf); tty_port_destroy(port); |