Fix a crash when calling tty_rel_free() while draining during closure.

Yesterday I got two reports of potential crashes, related to TTY
deallocation during device closure. When a thread is in TF_OPENCLOSE,
draining its output upon closure, we should not allow calls to
tty_rel_free() to happen at the same time. This could cause the TTY to
be torn down twice.

PR:		kern/127561
Reported by:	KOIE Hidetaka <koie suri co jp>
Discussed with:	thompsa
This commit is contained in:
Ed Schouten 2008-09-24 11:16:09 +00:00
parent a0ca087183
commit 4c7428e1ff

@ -924,8 +924,8 @@ tty_rel_free(struct tty *tp)
tty_lock_assert(tp, MA_OWNED);
if (tp->t_sessioncnt != 0 ||
(tp->t_flags & (TF_GONE|TF_OPENED|TF_HOOK)) != TF_GONE) {
#define TF_ACTIVITY (TF_GONE|TF_OPENED|TF_HOOK|TF_OPENCLOSE)
if (tp->t_sessioncnt != 0 || (tp->t_flags & TF_ACTIVITY) != TF_GONE) {
/* TTY is still in use. */
tty_unlock(tp);
return;