Commit 81c79838 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: pty, fix tty buffers leak

After commit "TTY: move tty buffers to tty_port", the tty buffers are
not freed in some drivers. This is because tty_port_destructor is not
called whenever a tty_port is freed. This was an assumption I counted
with but was unfortunately untrue. So fix the drivers to fulfil this
assumption.

PTY is one of those, here we just need to use tty_port_put instead of
kfree. (Assuming tty_port_destructor does not need port->ops to be set
which we change here too.)
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7342c59a
......@@ -408,7 +408,7 @@ static void pty_unix98_shutdown(struct tty_struct *tty)
static void pty_cleanup(struct tty_struct *tty)
{
tty->port->itty = NULL;
kfree(tty->port);
tty_port_put(tty->port);
}
/* Traditional BSD devices */
......
......@@ -128,7 +128,7 @@ static void tty_port_destructor(struct kref *kref)
if (port->xmit_buf)
free_page((unsigned long)port->xmit_buf);
tty_buffer_free_all(port);
if (port->ops->destruct)
if (port->ops && port->ops->destruct)
port->ops->destruct(port);
else
kfree(port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment