소스 검색

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>
Rasmus Villemoes 11 년 전
부모
커밋
07584d4a35
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      drivers/tty/pty.c

+ 1 - 1
drivers/tty/pty.c

@@ -388,7 +388,7 @@ err_deinit_tty:
 	deinitialize_tty_struct(o_tty);
 	deinitialize_tty_struct(o_tty);
 	free_tty_struct(o_tty);
 	free_tty_struct(o_tty);
 err_put_module:
 err_put_module:
-	module_put(o_tty->driver->owner);
+	module_put(driver->other->owner);
 err:
 err:
 	kfree(ports[0]);
 	kfree(ports[0]);
 	kfree(ports[1]);
 	kfree(ports[1]);