From: Jiri Slaby Date: Tue, 7 Aug 2012 19:47:26 +0000 (+0200) Subject: TTY: pty, stop passing NULL to free_tty_struct X-Git-Tag: v3.7-rc1~172^2~164 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f9ea7ad7be10dca95e7ca57221c5f81be48d852;p=profile%2Fivi%2Fkernel-x86-ivi.git TTY: pty, stop passing NULL to free_tty_struct In case alloc_tty_struct fails in pty_common_install, we pass NULL to free_tty_struct. This is invalid as the function is not ready to cope with that. And even if it was, it is not nice to do that anyway. Signed-off-by: Jiri Slaby Reported-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 4399f1d..d9ea9e2 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -303,9 +303,11 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty, int retval = -ENOMEM; o_tty = alloc_tty_struct(); + if (!o_tty) + goto err; ports[0] = kmalloc(sizeof **ports, GFP_KERNEL); ports[1] = kmalloc(sizeof **ports, GFP_KERNEL); - if (!o_tty || !ports[0] || !ports[1]) + if (!ports[0] || !ports[1]) goto err_free_tty; if (!try_module_get(driver->other->owner)) { /* This cannot in fact currently happen */ @@ -360,6 +362,7 @@ err_free_tty: kfree(ports[0]); kfree(ports[1]); free_tty_struct(o_tty); +err: return retval; }