I am using PREFast to check some driver code build for Windows7. The following line of code
stackDeviceObject = IoAttachDeviceToDeviceStack(deviceObject, PhysicalDeviceObject);
Gives the warning:
warning 28107: The Memory 'deviceObject' must be held when calling 'IoAttachDeviceToDeviceStack'.
deviceObject is obtained with an earlier call to IoCreateDevice. Does anyone know what this warning means and how to get rid of it?
The PREfast help says "A resource that the program must acquire before calling the function was not acquired when the function was called. As a result, the function call will fail."
The example that the help page provides surrounds a pair of calls to ExAcquireResourceLite and ExReleaseResourceLite (which gives this warning) between calls to KaEnterCriticalRegion and KaLeaveCriticalRegion, which then supposedly gets rid of the warning, but I don't know how to apply this info to my call to IoAttachDeviceToDeviceStack.
Any advice would be appreciated.