| From: Rasmus Villemoes <linux@rasmusvillemoes.dk> |
| Date: Sun, 13 Jul 2014 01:44:00 +0200 |
| Subject: drivers: tty: Fix use-after-free in pty_common_install |
| |
| commit 07584d4a356ef52c084e1e4fedc22858ffc2f8b2 upstream. |
| |
| 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> |
| Signed-off-by: Ben Hutchings <ben@decadent.org.uk> |
| --- |
| drivers/tty/pty.c | 2 +- |
| 1 file changed, 1 insertion(+), 1 deletion(-) |
| |
| --- a/drivers/tty/pty.c |
| +++ b/drivers/tty/pty.c |
| @@ -391,7 +391,7 @@ err_deinit_tty: |
| deinitialize_tty_struct(o_tty); |
| free_tty_struct(o_tty); |
| err_put_module: |
| - module_put(o_tty->driver->owner); |
| + module_put(driver->other->owner); |
| err: |
| kfree(ports[0]); |
| kfree(ports[1]); |