stos: pool: Protect pool structures with lock
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
+8
-1
@@ -179,6 +179,7 @@ ExAllocatePoolWithTag(POOL_TYPE Type, USIZE ByteCount, ULONG Tag)
|
||||
{
|
||||
KPCR *ThisCore;
|
||||
MEMORY_POOL *AllocPool;
|
||||
VOID *Base;
|
||||
|
||||
if (ByteCount == 0) {
|
||||
return NULL;
|
||||
@@ -195,6 +196,7 @@ ExAllocatePoolWithTag(POOL_TYPE Type, USIZE ByteCount, ULONG Tag)
|
||||
|
||||
ThisCore = HalKpcrCurrent();
|
||||
AllocPool = &ThisCore->AllocPool;
|
||||
KeSpinLockAcquire(&AllocPool->Lock, false);
|
||||
|
||||
/*
|
||||
* Ensure that the byte count is aligned by the minimum granularity
|
||||
@@ -207,10 +209,14 @@ ExAllocatePoolWithTag(POOL_TYPE Type, USIZE ByteCount, ULONG Tag)
|
||||
"allocation in pool #%d exceeds page size\n",
|
||||
AllocPool->Id
|
||||
);
|
||||
|
||||
KeSpinLockRelease(&AllocPool->Lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return AllocatePoolWithTag(AllocPool, Type, ByteCount, Tag);
|
||||
Base = AllocatePoolWithTag(AllocPool, Type, ByteCount, Tag);
|
||||
KeSpinLockRelease(&AllocPool->Lock);
|
||||
return Base;
|
||||
}
|
||||
|
||||
ST_STATUS
|
||||
@@ -225,6 +231,7 @@ ExPoolInit(MEMORY_POOL *Pool)
|
||||
}
|
||||
|
||||
Pool->Id = PoolCount;
|
||||
KeSpinLockInit(&Pool->Lock, "ex-pool");
|
||||
DTRACE("bringing up pool #%d\n", Pool->Id);
|
||||
|
||||
/* Initialize the pools */
|
||||
|
||||
Reference in New Issue
Block a user