]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/tty/tty_port.c
TTY: pty, fix tty buffers leak
[karo-tx-linux.git] / drivers / tty / tty_port.c
index d7bdd8d0c23f0faa832aee87447af772958ceb13..fdc42c2d565f4f70fc9495b99a025a37894e9215 100644 (file)
@@ -21,6 +21,7 @@
 void tty_port_init(struct tty_port *port)
 {
        memset(port, 0, sizeof(*port));
+       tty_buffer_init(port);
        init_waitqueue_head(&port->open_wait);
        init_waitqueue_head(&port->close_wait);
        init_waitqueue_head(&port->delta_msr_wait);
@@ -126,7 +127,8 @@ static void tty_port_destructor(struct kref *kref)
        struct tty_port *port = container_of(kref, struct tty_port, kref);
        if (port->xmit_buf)
                free_page((unsigned long)port->xmit_buf);
-       if (port->ops->destruct)
+       tty_buffer_free_all(port);
+       if (port->ops && port->ops->destruct)
                port->ops->destruct(port);
        else
                kfree(port);