/*++

    Copyright (c) Microsoft Corporation.  All rights reserved.

Rule Name:

    SpinlockRelease

Domain:

    ndis

Rule ID:

    Not Applicable

Description:

    The SpinLockRelease rule specifies that a driver must not release a SpinLock without first acquiring it. 
    
    Related Rule:
    SpinLockDprRelease

Help Link:

    https://go.microsoft.com/fwlink/?LinkId=507366

--*/




#include "slic_base.h"

state{
   enum {initial,unlocked,locked} s = initial;
}
watch NdisAllocateSpinLock.entry.$1;


[NdisReleaseSpinLock,NdisDprReleaseSpinLock].exit[guard $1]
{
    if ((s == unlocked) || (s == initial))
    {
        abort "The driver is calling $fname without first acquiring the spinlock.";
    } 
    else 
    {
        s = unlocked;
    }
}

[NdisAcquireSpinLock,NdisDprAcquireSpinLock].exit[guard $1]
{  
    s = locked;
}
