* [PATCH] ttyprintk: Fix NULL pointer deref by setting tty_port ops after initializing port
@ 2013-05-10 22:40 Darrick J. Wong
0 siblings, 0 replies; only message in thread
From: Darrick J. Wong @ 2013-05-10 22:40 UTC (permalink / raw)
To: Jiri Slaby, Greg Kroah-Hartman, Arnd Bergmann; +Cc: linux-kernel
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>
---
drivers/char/ttyprintk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index 4945bd3..d5d2e4a 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -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,
@@ -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";
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-05-10 22:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-10 22:40 [PATCH] ttyprintk: Fix NULL pointer deref by setting tty_port ops after initializing port Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®