Skip to content

Commit

Permalink
TTY: ttyprintk, initialize tty_port earlier
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiri Slaby authored and Greg Kroah-Hartman committed Aug 10, 2012
1 parent ee8b593 commit 536a344
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/char/ttyprintk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 536a344

Please sign in to comment.