Change ExFreePool to ExFreePoolWithTag

Don't call RtlFreeUnicodeString if the string wasn't created by RtlAnsiStringToUnicodeString or RtlUpcaseUnicodeString
Implement ExRosQueryNonPagedPoolTag
Add BAD_POOL_CALLER code

svn path=/trunk/; revision=15008
This commit is contained in:
Hervé Poussineau 2005-05-05 17:20:10 +00:00
parent 11670a0523
commit bcbeeea71f
9 changed files with 52 additions and 23 deletions

View file

@ -91,7 +91,7 @@ CmiObjectParse(PVOID ParsedObject,
{ {
ExReleaseResourceLite(&CmiRegistryLock); ExReleaseResourceLite(&CmiRegistryLock);
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
RtlFreeUnicodeString(&KeyName); ExFreePool(KeyName.Buffer);
return Status; return Status;
} }
if (FoundObject == NULL) if (FoundObject == NULL)
@ -107,7 +107,7 @@ CmiObjectParse(PVOID ParsedObject,
{ {
ExReleaseResourceLite(&CmiRegistryLock); ExReleaseResourceLite(&CmiRegistryLock);
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
RtlFreeUnicodeString(&KeyName); ExFreePool(KeyName.Buffer);
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
@ -140,7 +140,7 @@ CmiObjectParse(PVOID ParsedObject,
wcscat(TargetPath.Buffer, EndPtr); wcscat(TargetPath.Buffer, EndPtr);
} }
RtlFreeUnicodeString(FullPath); ExFreePool(FullPath->Buffer);
RtlFreeUnicodeString(&LinkPath); RtlFreeUnicodeString(&LinkPath);
FullPath->Length = TargetPath.Length; FullPath->Length = TargetPath.Length;
FullPath->MaximumLength = TargetPath.MaximumLength; FullPath->MaximumLength = TargetPath.MaximumLength;
@ -153,7 +153,7 @@ CmiObjectParse(PVOID ParsedObject,
*NextObject = NULL; *NextObject = NULL;
RtlFreeUnicodeString(&KeyName); ExFreePool(KeyName.Buffer);
return(STATUS_REPARSE); return(STATUS_REPARSE);
} }
} }
@ -173,7 +173,7 @@ CmiObjectParse(PVOID ParsedObject,
{ {
ExReleaseResourceLite(&CmiRegistryLock); ExReleaseResourceLite(&CmiRegistryLock);
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
RtlFreeUnicodeString(&KeyName); ExFreePool(KeyName.Buffer);
return(Status); return(Status);
} }
/* Add the keep-alive reference */ /* Add the keep-alive reference */
@ -224,8 +224,8 @@ CmiObjectParse(PVOID ParsedObject,
wcscat(TargetPath.Buffer, EndPtr); wcscat(TargetPath.Buffer, EndPtr);
} }
RtlFreeUnicodeString(FullPath); ExFreePool(FullPath->Buffer);
RtlFreeUnicodeString(&LinkPath); ExFreePool(LinkPath.Buffer);
FullPath->Length = TargetPath.Length; FullPath->Length = TargetPath.Length;
FullPath->MaximumLength = TargetPath.MaximumLength; FullPath->MaximumLength = TargetPath.MaximumLength;
FullPath->Buffer = TargetPath.Buffer; FullPath->Buffer = TargetPath.Buffer;
@ -237,7 +237,7 @@ CmiObjectParse(PVOID ParsedObject,
*NextObject = NULL; *NextObject = NULL;
RtlFreeUnicodeString(&KeyName); ExFreePool(KeyName.Buffer);
return(STATUS_REPARSE); return(STATUS_REPARSE);
} }
} }
@ -258,7 +258,7 @@ CmiObjectParse(PVOID ParsedObject,
*NextObject = FoundObject; *NextObject = FoundObject;
RtlFreeUnicodeString(&KeyName); ExFreePool(KeyName.Buffer);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }

View file

@ -18,6 +18,7 @@
#define TAG_DEVICE_EXTENSION TAG('D', 'E', 'X', 'T') #define TAG_DEVICE_EXTENSION TAG('D', 'E', 'X', 'T')
#define TAG_SHUTDOWN_ENTRY TAG('S', 'H', 'U', 'T') #define TAG_SHUTDOWN_ENTRY TAG('S', 'H', 'U', 'T')
#define TAG_IO_TIMER TAG('I', 'O', 'T', 'M')
static ULONG IopDeviceObjectNumber = 0; static ULONG IopDeviceObjectNumber = 0;
@ -589,7 +590,7 @@ IoDeleteDevice(PDEVICE_OBJECT DeviceObject)
if (DeviceObject->Timer) if (DeviceObject->Timer)
{ {
IopRemoveTimerFromTimerList(DeviceObject->Timer); IopRemoveTimerFromTimerList(DeviceObject->Timer);
ExFreePool(DeviceObject->Timer); ExFreePoolWithTag(DeviceObject->Timer, TAG_IO_TIMER);
} }
/* Remove device from driver device list */ /* Remove device from driver device list */

View file

@ -871,7 +871,7 @@ STDCALL
IoFreeIrp(PIRP Irp) IoFreeIrp(PIRP Irp)
{ {
/* Free the pool memory associated with it */ /* Free the pool memory associated with it */
ExFreePool(Irp); ExFreePoolWithTag(Irp, TAG_IRP);
} }
/* /*
@ -1253,7 +1253,7 @@ IoSecondStageCompletion(PKAPC Apc,
/* Also check if we should de-allocate it */ /* Also check if we should de-allocate it */
if (Irp->Flags & IRP_DEALLOCATE_BUFFER) if (Irp->Flags & IRP_DEALLOCATE_BUFFER)
{ {
ExFreePool(Irp->AssociatedIrp.SystemBuffer); ExFreePoolWithTag(Irp->AssociatedIrp.SystemBuffer, TAG_SYS_BUF);
} }
} }

View file

@ -132,7 +132,7 @@ IoFreeMdl(PMDL Mdl)
MmPrepareMdlForReuse(Mdl); MmPrepareMdlForReuse(Mdl);
ExFreePool(Mdl); ExFreePoolWithTag(Mdl, TAG_MDL);
} }

View file

@ -812,7 +812,7 @@ MmFreeMemoryArea(
} }
} }
ExFreePool(MemoryArea); ExFreePoolWithTag(MemoryArea, TAG_MAREA);
DPRINT("MmFreeMemoryAreaByNode() succeeded\n"); DPRINT("MmFreeMemoryAreaByNode() succeeded\n");

View file

@ -16,7 +16,7 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
#define TAG_MDL TAG('M', 'M', 'D', 'L') #define TAG_MDL TAG('M', 'D', 'L', ' ')
#define MI_MDL_MAPPING_REGION_SIZE (256*1024*1024) #define MI_MDL_MAPPING_REGION_SIZE (256*1024*1024)

View file

@ -1458,6 +1458,28 @@ static BLOCK_HDR* get_block(unsigned int size, unsigned long alignment)
#endif /* not WHOLE_PAGE_ALLOCATIONS */ #endif /* not WHOLE_PAGE_ALLOCATIONS */
ULONG STDCALL
ExRosQueryNonPagedPoolTag ( PVOID Addr )
{
#ifdef WHOLE_PAGE_ALLOCATIONS /* WHOLE_PAGE_ALLOCATIONS */
UNIMPLEMENTED;
return 0;
#else /* not WHOLE_PAGE_ALLOCATIONS */
BLOCK_HDR* blk=address_to_block(Addr);
if (blk->Magic != BLOCK_HDR_USED_MAGIC)
KEBUGCHECK(0);
if (blk->Magic == BLOCK_HDR_FREE_MAGIC)
KEBUGCHECK(0);
return blk->Used.Tag;
#endif /* WHOLE_PAGE_ALLOCATIONS */
}
VOID STDCALL ExFreeNonPagedPool (PVOID block) VOID STDCALL ExFreeNonPagedPool (PVOID block)
/* /*
* FUNCTION: Releases previously allocated memory * FUNCTION: Releases previously allocated memory

View file

@ -987,6 +987,14 @@ Language=English
INVALID_WORK_QUEUE_ITEM INVALID_WORK_QUEUE_ITEM
. .
MessageId=0xC2
Severity=Success
Facility=System
SymbolicName=BAD_POOL_CALLER
Language=English
BAD_POOL_CALLER
.
MessageId=0xE1 MessageId=0xE1
Severity=Success Severity=Success
Facility=System Facility=System

View file

@ -507,7 +507,7 @@ ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
if (current) if (current)
RtlpCreateUnicodeString (RemainingPath, current, NonPagedPool); RtlpCreateUnicodeString (RemainingPath, current, NonPagedPool);
RtlFreeUnicodeString (&PathString); ExFreePool(PathString.Buffer);
*ReturnedObject = CurrentObject; *ReturnedObject = CurrentObject;
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -806,7 +806,7 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL,
} }
RtlFreeUnicodeString(&Header->Name); RtlFreeUnicodeString(&Header->Name);
RtlFreeUnicodeString(&RemainingPath); RtlFreeUnicodeString(&RemainingPath);
ExFreePool(Header); ExFreePoolWithTag(Header, Header->ObjectType->Tag);
DPRINT("Create Failed\n"); DPRINT("Create Failed\n");
return Status; return Status;
} }
@ -1000,7 +1000,7 @@ ObpDeleteObject(POBJECT_HEADER Header)
} }
DPRINT("ObPerformRetentionChecks() = Freeing object\n"); DPRINT("ObPerformRetentionChecks() = Freeing object\n");
ExFreePool(Header); ExFreePoolWithTag(Header, Header->ObjectType->Tag);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -1010,16 +1010,14 @@ VOID STDCALL
ObpDeleteObjectWorkRoutine (IN PVOID Parameter) ObpDeleteObjectWorkRoutine (IN PVOID Parameter)
{ {
PRETENTION_CHECK_PARAMS Params = (PRETENTION_CHECK_PARAMS)Parameter; PRETENTION_CHECK_PARAMS Params = (PRETENTION_CHECK_PARAMS)Parameter;
/* ULONG Tag; */ /* See below */ ULONG Tag;
ASSERT(Params); ASSERT(Params);
ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); /* We need PAGED_CODE somewhere... */ ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); /* We need PAGED_CODE somewhere... */
/* Turn this on when we have ExFreePoolWithTag Tag = Params->ObjectHeader->ObjectType->Tag;
Tag = Params->ObjectHeader->ObjectType->Tag; */
ObpDeleteObject(Params->ObjectHeader); ObpDeleteObject(Params->ObjectHeader);
ExFreePool(Params); ExFreePoolWithTag(Params, Tag);
/* ExFreePoolWithTag(Params, Tag); */
} }