summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2003-06-19 18:13:07 +0000
committeralfred <alfred@FreeBSD.org>2003-06-19 18:13:07 +0000
commitc618ac833871991c8f6b2717bee6d9773f396ea3 (patch)
tree77350fa7351b4d53c0e19d6fdaa168a9f0ac19a2
parent44b935029a9cfbe1e42a26522d43fe9a710b740b (diff)
downloadFreeBSD-src-c618ac833871991c8f6b2717bee6d9773f396ea3.zip
FreeBSD-src-c618ac833871991c8f6b2717bee6d9773f396ea3.tar.gz
Unlock the struct file lock before aquiring Giant, otherwise
we can deadlock because of lock order reversals. This was not caught because Witness ignores pool mutexes right now. Diagnosis and help: truckman Noticed by: pho
-rw-r--r--sys/kern/kern_descrip.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index ca11323..667812a 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -2010,6 +2010,8 @@ fdrop_locked(fp, td)
FILE_UNLOCK(fp);
return (0);
}
+ /* We have the last ref so we can proceed without the file lock. */
+ FILE_UNLOCK(fp);
mtx_lock(&Giant);
if (fp->f_count < 0)
panic("fdrop: count < 0");
@@ -2019,10 +2021,8 @@ fdrop_locked(fp, td)
lf.l_len = 0;
lf.l_type = F_UNLCK;
vp = fp->f_data;
- FILE_UNLOCK(fp);
(void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK);
- } else
- FILE_UNLOCK(fp);
+ }
if (fp->f_ops != &badfileops)
error = fo_close(fp, td);
else
OpenPOWER on IntegriCloud