0

The driver in the title works with a PCIe card to get some data from outside world to a PC.

The driver will allocate tens of MB's memory when it starts up, then user program can map these memory to its own address space, then the data can be put there by the card to be accessed by user program.

My question:

  1. Suppose user program crashs after it mapped the memory or it forgets to unmap the memory before it exits, will that cause any resource leaking?
  2. If the answer of first question is true, is there anything can be done in the driver to avoid the leaking?

Any suggestion will be appreciated.

wilx
  • 17,697
  • 6
  • 59
  • 114
Gang YIN
  • 2,509
  • 2
  • 21
  • 25
  • How are you allocating the memory? How is the memory being mapped into the user's address space? – Harry Johnston Aug 09 '13 at 22:30
  • @HarryJohnston, the memory is allocated by calling WdfCommonBufferCreate while it's mapped to user space by MmMapIoSpace. – Gang YIN Aug 12 '13 at 04:51
  • 1
    You must also be doing something else to give the user process in question access to that virtual address space? What, if anything, is the user process doing to access the memory in question? In any case, according to the documentation, if the memory was allocated by the driver with WdfCommonBufferCreate, the driver must delete it when it is no longer needed, either by calling WdfObjectDelete or by deleting the associated grandparent framework device object. I don't believe there's anything the user process can do to affect the process in either way. – Harry Johnston Aug 12 '13 at 21:57

0 Answers0