[wdmaudiodev] AVStream driver & globally allocated memory

  • From: Alexander Ivash <elderorb@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Sun, 19 Jun 2016 17:18:19 +0300

What are the right places to allocate/de-allocate memory for global
variables in AVStream drivers?

At the moment I'm allocating memory inside DriverEntry right after
KsInitializeDriver call and de-allocate inside the hook for
'DriverUnload', which I installed also after KsInitializeDriver call.

Is it correct way of working with global variables? I'm asking because
from time to time I'm getting BSODs with the following error:

BAD_POOL_CALLER (c2)
The current thread is making a bad pool request.  Typically this is at
a bad IRQL level or double freeing the same allocation, etc.
Arguments:
Arg1: 0000000000000007, Attempt to free pool which was already freed
Arg2: 000000000000126c, (reserved)
Arg3: 0000000000080008, Memory contents of the pool block
Arg4: ffffe000f8f23f10, Address of the block of pool being deallocated

Based on the stack trace it is caused by my attempt to de-allocate
global variable. So it looks like this memory might have been already
freed by someone else, but the issue is that there should be no
'someone else'. Is there any driver-related magic involved here, like
'all the non-paged pool allocations gets unallocated automatically by
the time of DriverUnload' or something like this? What is the
recommended way of working with driver-global (not filter-specific)
data?

Regards, Alexander
******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

Other related posts: