[lkml]   [2013]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v3 15/23] tty: Don't restart ldisc on hangup if racing ldisc kill
Asynchronous hangups (such as from carrier loss) can race with the
final tty release. Because there is no mechanism to prevent an async
hangup from being scheduled, waiting for the hangup to complete is
insufficient to prevent racing between ldisc hangup and ldisc kill.
Eg., immediately after flush_work() returns, an async hangup
could be scheduled, thus restarting a new ldisc.

Instead, prevent hangup from restarting a new ldisc when the tty is
being destroyed.

Signed-off-by: Peter Hurley <>
drivers/tty/tty_ldisc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 8a86a72..e0fdfec 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -884,7 +884,7 @@ void tty_ldisc_hangup(struct tty_struct *tty)
* Shutdown the current line discipline, and reset it to
* N_TTY if need be.
- * Avoid racing set_ldisc or tty_ldisc_release
+ * Avoid racing set_ldisc or tty_ldisc_kill

@@ -892,7 +892,7 @@ void tty_ldisc_hangup(struct tty_struct *tty)
reopen it. We could defer this to the next open but
it means auditing a lot of other paths so this is
a FIXME */
- if (tty_ldisc_hangup_halt(tty)) {
+ if (tty_ldisc_hangup_halt(tty) && !test_bit(TTY_CLOSING, &tty->flags)) {
if (reset == 0) {

if (!tty_ldisc_reinit(tty, tty->termios.c_line))

 \ /
  Last update: 2013-02-05 23:01    [W:0.433 / U:1.688 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site