none
NdisMFreeSharedMemory leading to a crash RRS feed

  • Question

  • Hi,

    In the MPHaltEx handler, I'm freeing resources which were allocated during the initialization of the miniport. So when the driver is unloaded or disabled, if I free the shared memory allocated then the system crashes. Crash dump report points to double freeing already freed shared memory. But I'm not explicitly freeing the shared memory elsewhere.

    But if I don't use NdisMFreeSharedMemory then the driver halt and unloading completes without any issues. But it doesn't seem to follow the steps mentioned in the https://msdn.microsoft.com/library/windows/hardware/ff559388

    I'm a bit perplexed by this. So I have 2 blocks of shared memory for Tx Buffers and Rx Buffers. Do I need NdisMDeregisterScatterGatherDma before I free the shared memory ? 


    With regards, Jenson Alex Pais

    Thursday, October 27, 2016 1:08 PM

Answers

  • Are you explicitly allocating the memory with NdisMAllocateSharedMemory or NdisMAllocateSharedMemoryAsyncEx  If not then do not free it with NdisMFreeSharedMemory.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    • Marked as answer by JENSON PAIS Friday, October 28, 2016 5:35 AM
    Thursday, October 27, 2016 6:14 PM

All replies

  • Are you explicitly allocating the memory with NdisMAllocateSharedMemory or NdisMAllocateSharedMemoryAsyncEx  If not then do not free it with NdisMFreeSharedMemory.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    • Marked as answer by JENSON PAIS Friday, October 28, 2016 5:35 AM
    Thursday, October 27, 2016 6:14 PM
  • Don,

    Cheers for the prompt reply.

    I am explicitly allocating shared memory using NdisMAllocateSharedMemory. So I was surprised when the driver unload ended up crashing while I tried to use NdisMFreeSharedMemory to free that shared memory block. Crash report mentioned that I was trying to free an already freed shared memory pool. 

    I'll try freeing it again and will attach the kerneldebug output if there is another crash. 

    ps: One of the parameters in the NdisMFreeSharedMemory was wrong which lead to the crash. Now driver unloads without any issues. 


    With regards, Jenson Alex Pais


    • Edited by JENSON PAIS Friday, October 28, 2016 5:36 AM Solved
    Thursday, October 27, 2016 6:46 PM