diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-08-07 15:47:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-10 16:29:57 -0400 |
commit | 536a3440a27f8687090bdf33468b003bc0f810cf (patch) | |
tree | 76f358685b2838f740df7e293101078177fa46e7 | |
parent | ee8b593affdf893012e57f4c54a21984d1b0d92e (diff) |
TTY: ttyprintk, initialize tty_port earlier
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 <jslaby@suse.cz>
Cc: Samo Pogacnik <samo_pogacnik@t-2.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/char/ttyprintk.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c index 08755c52fc5f..be1c3fb186c1 100644 --- a/drivers/char/ttyprintk.c +++ b/drivers/char/ttyprintk.c | |||
@@ -180,6 +180,10 @@ static int __init ttyprintk_init(void) | |||
180 | int ret = -ENOMEM; | 180 | int ret = -ENOMEM; |
181 | void *rp; | 181 | void *rp; |
182 | 182 | ||
183 | tty_port_init(&tpk_port.port); | ||
184 | tpk_port.port.ops = &null_ops; | ||
185 | mutex_init(&tpk_port.port_write_mutex); | ||
186 | |||
183 | ttyprintk_driver = alloc_tty_driver(1); | 187 | ttyprintk_driver = alloc_tty_driver(1); |
184 | if (!ttyprintk_driver) | 188 | if (!ttyprintk_driver) |
185 | return ret; | 189 | return ret; |
@@ -210,10 +214,6 @@ static int __init ttyprintk_init(void) | |||
210 | goto error; | 214 | goto error; |
211 | } | 215 | } |
212 | 216 | ||
213 | tty_port_init(&tpk_port.port); | ||
214 | tpk_port.port.ops = &null_ops; | ||
215 | mutex_init(&tpk_port.port_write_mutex); | ||
216 | |||
217 | return 0; | 217 | return 0; |
218 | 218 | ||
219 | error: | 219 | error: |