Driver Verifier and KeWaitForMultipleObjects

Hi,

I get a DRIVER_VERIFIER_DETECTED_VIOLATION (c4) when I run the code below:

void* objects = { &mutex, &shutDownEvent };
KWAIT_BLOCK wait_block[2];
NTSTATUS status;

status = KeWaitForMultipleObjects( 2, objects, WaitAny, Executive,
KernelMode, FALSE, NULL, wait_block );
if (status == 0) {

KeReleaseMutex( &mutex, FALSE ); <– BugCheck C4, {1007, 81c18fdc,
ffadf618, 0}
} else if (status == 1)
// cleanup
} else {
// handle error
}

The 0x1007 code maps to the Deadlock Detection error:
“Unacquired resource: A resource is being released without having first been
acquired.”

If I inspect the mutex in WinDbg it appears to have been acquired. If I
disable the Deadlock Detection from Driver Verifier everything seems to work
just fine.

Is this a bug in Driver Verifier or am I using KeWaitForMultipleObjects
incorrectly?

Thanks,
Carsten Schmidt