* [PATCH] FIx race on tty close
@ 2004-05-06 3:19 Benjamin Herrenschmidt
0 siblings, 0 replies; only message in thread
From: Benjamin Herrenschmidt @ 2004-05-06 3:19 UTC (permalink / raw)
To: Russell King; +Cc: Linux Kernel list
Hi Russell !
Here's the patch fixing the race we talked about on irc, where the ldisc
close can race with the flush_to_ldisc workqueue.
This patch fixes it by killing the workqueue first.
Please bounce to Andrew if you are happy with it.
Ben.
===== drivers/char/tty_io.c 1.136 vs edited =====
--- 1.136/drivers/char/tty_io.c Tue Apr 13 03:54:18 2004
+++ edited/drivers/char/tty_io.c Mon May 3 11:50:46 2004
@@ -1267,6 +1267,18 @@
#endif
/*
+ * Prevent flush_to_ldisc() from rescheduling the work for later. Then
+ * kill any delayed work.
+ */
+ clear_bit(TTY_DONT_FLIP, &tty->flags);
+ cancel_delayed_work(&tty->flip.work);
+
+ /*
+ * Wait for ->hangup_work and ->flip.work handlers to terminate
+ */
+ flush_scheduled_work();
+
+ /*
* Shutdown the current line discipline, and reset it to N_TTY.
* N.B. why reset ldisc when we're releasing the memory??
*/
@@ -1281,19 +1293,7 @@
(o_tty->ldisc.close)(o_tty);
module_put(o_tty->ldisc.owner);
o_tty->ldisc = ldiscs[N_TTY];
- }
-
- /*
- * Prevent flush_to_ldisc() from rescheduling the work for later. Then
- * kill any delayed work.
- */
- clear_bit(TTY_DONT_FLIP, &tty->flags);
- cancel_delayed_work(&tty->flip.work);
-
- /*
- * Wait for ->hangup_work and ->flip.work handlers to terminate
- */
- flush_scheduled_work();
+ }
/*
* The release_mem function takes care of the details of clearing
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-05-06 3:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-06 3:19 [PATCH] FIx race on tty close Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox