aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/ttyprintk.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2013-05-10 18:40:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-21 13:13:23 -0400
commitb5325a02aa84c794cf520d6d68cae4b150988a32 (patch)
tree1f91407c6ac96bed7c0dea018ea0315648601954 /drivers/char/ttyprintk.c
parent89fb9e7c3423662f4969a1e8ef0f5d44835d2381 (diff)
ttyprintk: Fix NULL pointer deref by setting tty_port ops after initializing 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 <darrick.wong@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char/ttyprintk.c')
-rw-r--r--drivers/char/ttyprintk.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index 4945bd3d18d0..d5d2e4a985aa 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -179,7 +179,6 @@ static int __init ttyprintk_init(void)
179{ 179{
180 int ret = -ENOMEM; 180 int ret = -ENOMEM;
181 181
182 tpk_port.port.ops = &null_ops;
183 mutex_init(&tpk_port.port_write_mutex); 182 mutex_init(&tpk_port.port_write_mutex);
184 183
185 ttyprintk_driver = tty_alloc_driver(1, 184 ttyprintk_driver = tty_alloc_driver(1,
@@ -190,6 +189,7 @@ static int __init ttyprintk_init(void)
190 return PTR_ERR(ttyprintk_driver); 189 return PTR_ERR(ttyprintk_driver);
191 190
192 tty_port_init(&tpk_port.port); 191 tty_port_init(&tpk_port.port);
192 tpk_port.port.ops = &null_ops;
193 193
194 ttyprintk_driver->driver_name = "ttyprintk"; 194 ttyprintk_driver->driver_name = "ttyprintk";
195 ttyprintk_driver->name = "ttyprintk"; 195 ttyprintk_driver->name = "ttyprintk";