Skip to content

Commit

Permalink
ttyprintk: Fix NULL pointer deref by setting tty_port ops after initi…
Browse files Browse the repository at this point in the history
…alizing port

tty_port_init() zeroes out the tty port, which means that we have to set the
ops pointer /after/, not before this call.  Otherwise, tty_port_open will crash
when it tries to deref ops, which is now a NULL pointer.

Signed-off-by: Darrick J. Wong <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
djwong authored and gregkh committed May 21, 2013
1 parent 89fb9e7 commit b5325a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/char/ttyprintk.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ static int __init ttyprintk_init(void)
{
int ret = -ENOMEM;

tpk_port.port.ops = &null_ops;
mutex_init(&tpk_port.port_write_mutex);

ttyprintk_driver = tty_alloc_driver(1,
Expand All @@ -190,6 +189,7 @@ static int __init ttyprintk_init(void)
return PTR_ERR(ttyprintk_driver);

tty_port_init(&tpk_port.port);
tpk_port.port.ops = &null_ops;

ttyprintk_driver->driver_name = "ttyprintk";
ttyprintk_driver->name = "ttyprintk";
Expand Down

0 comments on commit b5325a0

Please sign in to comment.