patch "serdev: ttyport: fix NULL-deref on hangup" added to tty-linus
Subsystems (3)
This is a note to let you know that I've just added the patch titled
serdev: ttyport: fix NULL-deref on hangup
to my tty git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
in the tty-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
Quoted 1 line
From
8bcd4e6a8decac251d55c4377e2e67f052777ce0Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Fri, 3 Nov 2017 15:30:55 +0100
Subject: serdev: ttyport: fix NULL-deref on hangup
Make sure to use a properly refcounted tty_struct in write_wake up to avoid dereferencing a NULL-pointer when a port is being hung up.
--- drivers/tty/serdev/serdev-ttyport.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/tty/serdev/serdev-ttyport.c +9 -2
@@ -49,12 +49,19 @@ static void ttyport_write_wakeup(struct tty_port *port) {struct serdev_controller *ctrl = port->client_data;struct serport *serport =serdev_controller_get_drvdata (ctrl); +struct tty_struct *tty; + + tty =tty_port_tty_get (port); +if (!tty) +return ; -if (test_and_clear_bit (TTY_DO_WRITE_WAKEUP , &port->tty->flags) && +if (test_and_clear_bit (TTY_DO_WRITE_WAKEUP , &tty->flags) &&test_bit (SERPORT_ACTIVE , &serport->flags))serdev_controller_write_wakeup (ctrl); -wake_up_interruptible_poll (&port->tty->write_wait,POLLOUT ); +wake_up_interruptible_poll (&tty->write_wait,POLLOUT ); + +tty_kref_put (tty); }static const struct tty_port_client_operations client_ops = {
Signature · 1 line
2.15.0