From: Peter Hurley Date: Thu, 19 Sep 2013 00:42:39 +0000 (-0400) Subject: tty: Prevent tty_port destruction if tty not released X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e3bfea23a62dccfd12875a6cc24fa5c77e8a3c07;p=linux-beck.git 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 Signed-off-by: Greg Kroah-Hartman --- 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);