aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-08-07 15:47:26 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-10 16:27:50 -0400
commit6f9ea7ad7be10dca95e7ca57221c5f81be48d852 (patch)
tree83749543072a6c0194ae4f065c023f6be2646185
parent090abf7b91645c1936ba959b1e1cd6d09110779c (diff)
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 <jslaby@suse.cz> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/pty.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 4399f1dbd131..d9ea9e2c9ec5 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,
303 int retval = -ENOMEM; 303 int retval = -ENOMEM;
304 304
305 o_tty = alloc_tty_struct(); 305 o_tty = alloc_tty_struct();
306 if (!o_tty)
307 goto err;
306 ports[0] = kmalloc(sizeof **ports, GFP_KERNEL); 308 ports[0] = kmalloc(sizeof **ports, GFP_KERNEL);
307 ports[1] = kmalloc(sizeof **ports, GFP_KERNEL); 309 ports[1] = kmalloc(sizeof **ports, GFP_KERNEL);
308 if (!o_tty || !ports[0] || !ports[1]) 310 if (!ports[0] || !ports[1])
309 goto err_free_tty; 311 goto err_free_tty;
310 if (!try_module_get(driver->other->owner)) { 312 if (!try_module_get(driver->other->owner)) {
311 /* This cannot in fact currently happen */ 313 /* This cannot in fact currently happen */
@@ -360,6 +362,7 @@ err_free_tty:
360 kfree(ports[0]); 362 kfree(ports[0]);
361 kfree(ports[1]); 363 kfree(ports[1]);
362 free_tty_struct(o_tty); 364 free_tty_struct(o_tty);
365err:
363 return retval; 366 return retval;
364} 367}
365 368