The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at C28104.

warning C28104: Resource that should have been acquired before function exit was not acquired

A function that is intended to acquire a resource before it exits has exited without acquiring the resource. This warning indicates that the function is annotated with __drv_acquiresResource but does not return having actually acquired the resource. If this function is a wrapper function, a path through the function did not reach the wrapped function. If the failure to reach the wrapped function is because the function returned an error and did not actually acquire the resource, you might need to use a conditional annotation (__drv_when).

If this function actually implements the acquisition of the resource, it might not be possible for PFD to detect that the resource is acquired. In that case, use a #pragma warning to suppress the error. You can probably place the #pragma on the line preceding the { that begins the function body. The calling functions still need the annotation, but the Code Analysis tool will not be able to detect that the resource was acquired.

__drv_acquireResourceGlobal(HWLock, lockid)  
void GetHardwareLock(lockid)  
#pragma warning (suppress: 28104)  
   // code to implement a hardware lock (which the Code Analysis tool can't recognize)