From 8e73fd395b8234b4a74562a1b84a8d9574ce6e3f Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 26 Apr 2009 12:26:16 -0700 Subject: [PATCH] Fix recursive lock in detached close of /dev/tty. A recursive lock and vp-held-after-release issue when close()ing a /dev/tty descriptor was resulting in a panic. Reported-by: Hasso Tepper --- sys/kern/tty_tty.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c index ce27467538..9b73517161 100644 --- a/sys/kern/tty_tty.c +++ b/sys/kern/tty_tty.c @@ -135,22 +135,22 @@ retry: /* * Avoid a nasty race if we block while getting the lock. */ - vhold(ttyvp); + vref(ttyvp); error = vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY); if (error) { - vdrop(ttyvp); + vrele(ttyvp); goto retry; } if (ttyvp != cttyvp(p) || (ttyvp->v_flag & VCTTYISOPEN) == 0) { kprintf("Warning: cttyclose: race avoided\n"); vn_unlock(ttyvp); - vdrop(ttyvp); + vrele(ttyvp); goto retry; } vclrflags(ttyvp, VCTTYISOPEN); error = VOP_CLOSE(ttyvp, FREAD|FWRITE); vn_unlock(ttyvp); - vdrop(ttyvp); + vrele(ttyvp); } else { error = 0; } -- 2.41.0