*** Assertion failed: (MemoryDescriptorList->MdlFlags & MDL_PAGES_LOCKED) != 0

Hi All,

I am writing a TDI filter driver.

In the the “Completion routine” for IRP_MJ_CREATE (TdiDispatchCreate), following are the sequence of calls:

TdiBuildInternalDeviceControlIrp
pContext = ExAllocatePoolWithTag
pMdl = IoAllocateMdl (pContext , …)
MmBuildMdlForNonPagedPool
TdiBuildQueryInformation
IoCallDriver

But I am getting following assertion
*** Assertion failed: (MemoryDescriptorList->MdlFlags & MDL_PAGES_LOCKED) != 0

On this assertion, DDK (under the title “Checked Build ASSERTs”) says that:
Most common routine which will provoke this error is MmUnlockPages.
The meaning of the asseriton is “The pages that comprise the buffer described by this MDL have not been locked.”

I am not calling MmUnlockPages. So who calls it ? and when ?
Do I need to lock the buffer (using MmProbeAndLockPages) ?

TIA
Abhijit