summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/tty/pty.c2
-rw-r--r--drivers/tty/tty_port.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 0ce0b3ec2bb..a541ec87593 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -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 */
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 416b42f7c34..fdc42c2d565 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -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);