Windows: buf redir queue mgmt scp can be null

buf_InsertToRedirQueue, buf_RemoveFromRedirQueue, and
buf_MoveToHeadOfRedirQueue can be passed a NULL cm_scache_t pointer.
If the pointer is NULL (as is the case during buf_Init() processing)
the scp->redirMx must not be obtained or a crash will occur.

Change-Id: I157091afd973a8b4789976c42de253831a2698a3
Reviewed-on: http://gerrit.openafs.org/7422
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
This commit is contained in:
Jeffrey Altman 2012-05-18 10:19:13 -04:00 committed by Jeffrey Altman
parent e04f324b5d
commit 564c9733e5

View File

@ -2596,7 +2596,9 @@ buf_InsertToRedirQueue(cm_scache_t *scp, cm_buf_t *bufp)
{
lock_AssertWrite(&buf_globalLock);
lock_ObtainMutex(&scp->redirMx);
if (scp) {
lock_ObtainMutex(&scp->redirMx);
}
if (bufp->qFlags & CM_BUF_QINLRU) {
_InterlockedAnd(&bufp->qFlags, ~CM_BUF_QINLRU);
@ -2617,9 +2619,9 @@ buf_InsertToRedirQueue(cm_scache_t *scp, cm_buf_t *bufp)
&bufp->redirq);
scp->redirLastAccess = bufp->redirLastAccess;
InterlockedIncrement(&scp->redirBufCount);
}
lock_ReleaseMutex(&scp->redirMx);
lock_ReleaseMutex(&scp->redirMx);
}
}
void
@ -2630,21 +2632,24 @@ buf_RemoveFromRedirQueue(cm_scache_t *scp, cm_buf_t *bufp)
if (!(bufp->qFlags & CM_BUF_QREDIR))
return;
lock_ObtainMutex(&scp->redirMx);
if (scp) {
lock_ObtainMutex(&scp->redirMx);
}
_InterlockedAnd(&bufp->qFlags, ~CM_BUF_QREDIR);
osi_QRemoveHT( (osi_queue_t **) &cm_data.buf_redirListp,
(osi_queue_t **) &cm_data.buf_redirListEndp,
&bufp->q);
buf_DecrementRedirCount();
if (scp) {
osi_QRemoveHT( (osi_queue_t **) &scp->redirQueueH,
(osi_queue_t **) &scp->redirQueueT,
&bufp->redirq);
InterlockedDecrement(&scp->redirBufCount);
}
lock_ReleaseMutex(&scp->redirMx);
InterlockedDecrement(&scp->redirBufCount);
lock_ReleaseMutex(&scp->redirMx);
}
}
void
@ -2654,7 +2659,9 @@ buf_MoveToHeadOfRedirQueue(cm_scache_t *scp, cm_buf_t *bufp)
if (!(bufp->qFlags & CM_BUF_QREDIR))
return;
lock_ObtainMutex(&scp->redirMx);
if (scp) {
lock_ObtainMutex(&scp->redirMx);
}
osi_QRemoveHT( (osi_queue_t **) &cm_data.buf_redirListp,
(osi_queue_t **) &cm_data.buf_redirListEndp,
@ -2671,7 +2678,7 @@ buf_MoveToHeadOfRedirQueue(cm_scache_t *scp, cm_buf_t *bufp)
(osi_queue_t **) &scp->redirQueueT,
&bufp->redirq);
scp->redirLastAccess = bufp->redirLastAccess;
}
lock_ReleaseMutex(&scp->redirMx);
lock_ReleaseMutex(&scp->redirMx);
}
}