tty: handle NULL parameters in free_tty_struct()

We sometimes pass NULL pointers to free_tty_struct().  One example where
it can happen is in the error handling code in pty_common_install().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Dan Carpenter 2012-07-24 12:52:04 +01:00 committed by Greg Kroah-Hartman
parent 4ac5d7050e
commit dc6802a771
1 changed files with 2 additions and 0 deletions

View File

@ -181,6 +181,8 @@ struct tty_struct *alloc_tty_struct(void)
void free_tty_struct(struct tty_struct *tty)
{
if (!tty)
return;
if (tty->dev)
put_device(tty->dev);
kfree(tty->write_buf);