提交 0b2588ca 编写于 作者: J Johan Hovold 提交者: Greg Kroah-Hartman

TTY: fix close of uninitialised ports

Make sure we do not make tty-driver callbacks or wait for port to drain
on uninitialised ports (e.g. when open failed) in
tty_port_close_start().

No callback, such as flush_buffer or wait_until_sent, needs to be made
on a port that has never been opened. Neither does it make much sense to
add drain delay for an uninitialised port.

Currently a drain delay of up to two seconds could be added when a tty
fails to open.
Signed-off-by: NJohan Hovold <jhovold@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 b74414f5
...@@ -487,14 +487,16 @@ int tty_port_close_start(struct tty_port *port, ...@@ -487,14 +487,16 @@ int tty_port_close_start(struct tty_port *port,
set_bit(ASYNCB_CLOSING, &port->flags); set_bit(ASYNCB_CLOSING, &port->flags);
tty->closing = 1; tty->closing = 1;
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);
/* Don't block on a stalled port, just pull the chain */
if (tty->flow_stopped) if (test_bit(ASYNCB_INITIALIZED, &port->flags)) {
tty_driver_flush_buffer(tty); /* Don't block on a stalled port, just pull the chain */
if (test_bit(ASYNCB_INITIALIZED, &port->flags) && if (tty->flow_stopped)
port->closing_wait != ASYNC_CLOSING_WAIT_NONE) tty_driver_flush_buffer(tty);
tty_wait_until_sent_from_close(tty, port->closing_wait); if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
if (port->drain_delay) tty_wait_until_sent_from_close(tty, port->closing_wait);
tty_port_drain_delay(port, tty); if (port->drain_delay)
tty_port_drain_delay(port, tty);
}
/* Flush the ldisc buffering */ /* Flush the ldisc buffering */
tty_ldisc_flush(tty); tty_ldisc_flush(tty);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册