Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers: tty: Fix use-after-free in pty_common_install

In 2c964a2f "drivers: tty: Merge alloc_tty_struct and
initialize_tty_struct", I messed up the refactorization of
pty_common_install, causing use-after-free and NULL pointer derefs on
various error paths. This should fix it.

Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Rasmus Villemoes and committed by
Greg Kroah-Hartman
07584d4a 2c964a2f

+1 -1
+1 -1
drivers/tty/pty.c
··· 388 388 deinitialize_tty_struct(o_tty); 389 389 free_tty_struct(o_tty); 390 390 err_put_module: 391 - module_put(o_tty->driver->owner); 391 + module_put(driver->other->owner); 392 392 err: 393 393 kfree(ports[0]); 394 394 kfree(ports[1]);