mirror of
https://github.com/torvalds/linux.git
synced 2026-05-13 21:32:16 -04:00
serdev: ttyport: fix NULL-deref on hangup
commit8bcd4e6a8dupstream. 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. Fixes:bed35c6dfa("serdev: add a tty port controller driver") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d415ccdd0b
commit
5a3da8bd93
@@ -57,12 +57,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;
|
||||
|
||||
if (test_and_clear_bit(TTY_DO_WRITE_WAKEUP, &port->tty->flags) &&
|
||||
tty = tty_port_tty_get(port);
|
||||
if (!tty)
|
||||
return;
|
||||
|
||||
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 = {
|
||||
|
||||
Reference in New Issue
Block a user