]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tty: Prevent tty_port destruction if tty not released
authorPeter Hurley <peter@hurleysoftware.com>
Thu, 19 Sep 2013 00:42:39 +0000 (20:42 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Sep 2013 01:08:34 +0000 (18:08 -0700)
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>
drivers/tty/tty_port.c

index f597e88a705d1fa8e65cf36ae98a61f84f20b9a3..7efbca474689ea93fa776436b2bb319033539056 100644 (file)
@@ -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);