diff options
author | Johan Hovold <jhovold@gmail.com> | 2013-03-07 09:55:53 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-18 19:27:54 -0400 |
commit | 0b2588cadf9f131614cb251e34f7be1f4e1a2e08 (patch) | |
tree | fedeac10644f0ac73734a9cdb91036fbf1eb09af /drivers/tty/tty_port.c | |
parent | b74414f5f3227d9db309bfaaea3ae889af01430a (diff) |
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: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_port.c')
-rw-r--r-- | drivers/tty/tty_port.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index 20426ccbd58b..969c3e675a76 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c | |||
@@ -487,14 +487,16 @@ int tty_port_close_start(struct tty_port *port, | |||
487 | set_bit(ASYNCB_CLOSING, &port->flags); | 487 | set_bit(ASYNCB_CLOSING, &port->flags); |
488 | tty->closing = 1; | 488 | tty->closing = 1; |
489 | spin_unlock_irqrestore(&port->lock, flags); | 489 | spin_unlock_irqrestore(&port->lock, flags); |
490 | /* Don't block on a stalled port, just pull the chain */ | 490 | |
491 | if (tty->flow_stopped) | 491 | if (test_bit(ASYNCB_INITIALIZED, &port->flags)) { |
492 | tty_driver_flush_buffer(tty); | 492 | /* Don't block on a stalled port, just pull the chain */ |
493 | if (test_bit(ASYNCB_INITIALIZED, &port->flags) && | 493 | if (tty->flow_stopped) |
494 | port->closing_wait != ASYNC_CLOSING_WAIT_NONE) | 494 | tty_driver_flush_buffer(tty); |
495 | tty_wait_until_sent_from_close(tty, port->closing_wait); | 495 | if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) |
496 | if (port->drain_delay) | 496 | tty_wait_until_sent_from_close(tty, port->closing_wait); |
497 | tty_port_drain_delay(port, tty); | 497 | if (port->drain_delay) |
498 | tty_port_drain_delay(port, tty); | ||
499 | } | ||
498 | /* Flush the ldisc buffering */ | 500 | /* Flush the ldisc buffering */ |
499 | tty_ldisc_flush(tty); | 501 | tty_ldisc_flush(tty); |
500 | 502 | ||