From 4f266f14c0721111a9d453c3358cddf77eb2641a Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 27 Sep 2013 18:02:52 -0400 Subject: [PATCH] Windows: cm_MergeStatus avoid lock recursion It is possible for cm_MergeStatus() to be called while the cm_buf_t.mx is already held. If it is a panic occurs. Test for refcount == 0 before acquiring the lock in addition to afterwards. If the refcount is not zero, then we do not need to acquire the lock in any case. Change-Id: I1b73a03f4745e524d7fdf8f9b231b420895ff0fa Reviewed-on: http://gerrit.openafs.org/10297 Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/WINNT/afsd/cm_scache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WINNT/afsd/cm_scache.c b/src/WINNT/afsd/cm_scache.c index 3595e9697d..d93955432a 100644 --- a/src/WINNT/afsd/cm_scache.c +++ b/src/WINNT/afsd/cm_scache.c @@ -1975,7 +1975,8 @@ long cm_MergeStatus(cm_scache_t *dscp, * so leave it in place. */ if (cm_FidCmp(&scp->fid, &bp->fid) == 0 && - lock_TryMutex(&bp->mx)) { + bp->refCount == 0 && + lock_TryMutex(&bp->mx)) { if (bp->refCount == 0 && !(bp->flags & (CM_BUF_READING | CM_BUF_WRITING | CM_BUF_DIRTY)) && !(bp->qFlags & CM_BUF_QREDIR)) {