Thread (55 messages) 55 messages, 4 authors, 2012-08-13

[PATCH 15/41] TTY: ttyprintk, initialize tty_port earlier

flat view
STALE5182d

From: Jiri Slaby <hidden>
Date: 2012-08-07 19:56:50
Subsystem: char and misc drivers, the rest · Maintainers: Arnd Bergmann, Greg Kroah-Hartman, Linus Torvalds

After tty_register_driver is called, it is too late to initialize a
guy with which we operate in open. When a process already called
open(2) on that node, the structures may be in use uninitialized.

Move the initialization prior to tty_register_driver.

Signed-off-by: Jiri Slaby <redacted>
Cc: Samo Pogacnik <redacted>
---
 drivers/char/ttyprintk.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index 08755c5..be1c3fb 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -180,6 +180,10 @@ static int __init ttyprintk_init(void)
 	int ret = -ENOMEM;
 	void *rp;
 
+	tty_port_init(&tpk_port.port);
+	tpk_port.port.ops = &null_ops;
+	mutex_init(&tpk_port.port_write_mutex);
+
 	ttyprintk_driver = alloc_tty_driver(1);
 	if (!ttyprintk_driver)
 		return ret;
@@ -210,10 +214,6 @@ static int __init ttyprintk_init(void)
 		goto error;
 	}
 
-	tty_port_init(&tpk_port.port);
-	tpk_port.port.ops = &null_ops;
-	mutex_init(&tpk_port.port_write_mutex);
-
 	return 0;
 
 error:
-- 
1.7.10.4

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help