Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f9ea7ad authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman
Browse files

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: default avatarJiri Slaby <jslaby@suse.cz>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 090abf7b
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -303,9 +303,11 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty,
	int retval = -ENOMEM;
	int retval = -ENOMEM;


	o_tty = alloc_tty_struct();
	o_tty = alloc_tty_struct();
	if (!o_tty)
		goto err;
	ports[0] = kmalloc(sizeof **ports, GFP_KERNEL);
	ports[0] = kmalloc(sizeof **ports, GFP_KERNEL);
	ports[1] = 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;
		goto err_free_tty;
	if (!try_module_get(driver->other->owner)) {
	if (!try_module_get(driver->other->owner)) {
		/* This cannot in fact currently happen */
		/* This cannot in fact currently happen */
@@ -360,6 +362,7 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty,
	kfree(ports[0]);
	kfree(ports[0]);
	kfree(ports[1]);
	kfree(ports[1]);
	free_tty_struct(o_tty);
	free_tty_struct(o_tty);
err:
	return retval;
	return retval;
}
}