From 24a14abf27698d4d27005910ce3cc9286640a27c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Fri, 28 Sep 2012 12:17:23 +0000 Subject: [PATCH] [NTOSKRNL] - ExFreePool --> ExFreePoolWithTag in some places. - Remove dead code (section.c) - Free resource (sysldr.c) svn path=/trunk/; revision=57412 --- reactos/ntoskrnl/cache/section/data.c | 2 +- reactos/ntoskrnl/io/iomgr/iofunc.c | 20 ++++++++++---------- reactos/ntoskrnl/io/iomgr/irq.c | 4 ++-- reactos/ntoskrnl/mm/ARM3/drvmgmt.c | 2 +- reactos/ntoskrnl/mm/ARM3/expool.c | 4 ++-- reactos/ntoskrnl/mm/ARM3/mminit.c | 2 +- reactos/ntoskrnl/mm/ARM3/pagfault.c | 2 +- reactos/ntoskrnl/mm/ARM3/procsup.c | 7 ++++++- reactos/ntoskrnl/mm/ARM3/sysldr.c | 23 ++++++++++++++--------- reactos/ntoskrnl/mm/ARM3/virtual.c | 4 ++-- reactos/ntoskrnl/mm/section.c | 19 +++++++------------ 11 files changed, 47 insertions(+), 42 deletions(-) diff --git a/reactos/ntoskrnl/cache/section/data.c b/reactos/ntoskrnl/cache/section/data.c index 5b1f40ea43d..a4982e342f9 100644 --- a/reactos/ntoskrnl/cache/section/data.c +++ b/reactos/ntoskrnl/cache/section/data.c @@ -555,7 +555,7 @@ MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject, { KeReleaseSpinLock(&FileObject->IrpListLock, OldIrql); DPRINTC("Free Segment %x\n", Segment); - ExFreePool(Segment); + ExFreePoolWithTag(Segment, TAG_MM_SECTION_SEGMENT); DPRINT("Filling out Segment info (previous data section)\n"); diff --git a/reactos/ntoskrnl/io/iomgr/iofunc.c b/reactos/ntoskrnl/io/iomgr/iofunc.c index 7882d70ca56..2d59c415aab 100644 --- a/reactos/ntoskrnl/io/iomgr/iofunc.c +++ b/reactos/ntoskrnl/io/iomgr/iofunc.c @@ -1347,7 +1347,7 @@ NtLockFile(IN HANDLE FileHandle, { /* Allocating failed, clean up and return the exception code */ IopCleanupAfterException(FileObject, Irp, Event, NULL); - if (LocalLength) ExFreePool(LocalLength); + if (LocalLength) ExFreePoolWithTag(LocalLength, TAG_LOCK); /* Return the exception code */ _SEH2_YIELD(return _SEH2_GetExceptionCode()); @@ -1450,7 +1450,7 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { /* Free buffer and return the exception code */ - if (AuxBuffer) ExFreePool(AuxBuffer); + if (AuxBuffer) ExFreePoolWithTag(AuxBuffer, TAG_SYSB); _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; @@ -1466,7 +1466,7 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, if (!NT_SUCCESS(Status)) { /* Fail */ - if (AuxBuffer) ExFreePool(AuxBuffer); + if (AuxBuffer) ExFreePoolWithTag(AuxBuffer, TAG_SYSB); return Status; } @@ -1539,7 +1539,7 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, { /* Allocating failed, clean up and return the exception code */ IopCleanupAfterException(FileObject, Irp, Event, NULL); - if (AuxBuffer) ExFreePool(AuxBuffer); + if (AuxBuffer) ExFreePoolWithTag(AuxBuffer, TAG_SYSB); /* Return the exception code */ _SEH2_YIELD(return _SEH2_GetExceptionCode()); @@ -1863,7 +1863,7 @@ NtQueryInformationFile(IN HANDLE FileHandle, _SEH2_END; /* Free the event */ - ExFreePool(Event); + ExFreePoolWithTag(Event, TAG_IO); } else { @@ -2465,7 +2465,7 @@ NtSetInformationFile(IN HANDLE FileHandle, * Someone else set the completion port in the * meanwhile, so dereference the port and fail. */ - ExFreePool(Context); + ExFreePoolWithTag(Context, IOC_TAG); ObDereferenceObject(Queue); Status = STATUS_INVALID_PARAMETER; } @@ -2524,7 +2524,7 @@ NtSetInformationFile(IN HANDLE FileHandle, _SEH2_END; /* Free the event */ - ExFreePool(Event); + ExFreePoolWithTag(Event, TAG_IO); } else { @@ -2555,7 +2555,7 @@ NtSetInformationFile(IN HANDLE FileHandle, { /* Clear it in the IRP for completion */ Irp->UserEvent = NULL; - ExFreePool(Event); + ExFreePoolWithTag(Event, TAG_IO); } /* Set the caller IOSB */ @@ -2722,7 +2722,7 @@ NtUnlockFile(IN HANDLE FileHandle, /* Allocate a buffer */ LocalLength = ExAllocatePoolWithTag(NonPagedPool, sizeof(LARGE_INTEGER), - TAG_LOCK); + TAG_LOCK); /* Set the length */ *LocalLength = CapturedLength; @@ -2733,7 +2733,7 @@ NtUnlockFile(IN HANDLE FileHandle, { /* Allocating failed, clean up and return the exception code */ IopCleanupAfterException(FileObject, Irp, NULL, Event); - if (LocalLength) ExFreePool(LocalLength); + if (LocalLength) ExFreePoolWithTag(LocalLength, TAG_LOCK); /* Return the exception code */ _SEH2_YIELD(return _SEH2_GetExceptionCode()); diff --git a/reactos/ntoskrnl/io/iomgr/irq.c b/reactos/ntoskrnl/io/iomgr/irq.c index 6d45b254343..37614fa4710 100644 --- a/reactos/ntoskrnl/io/iomgr/irq.c +++ b/reactos/ntoskrnl/io/iomgr/irq.c @@ -103,7 +103,7 @@ IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, if (FirstRun) { /* We failed early so just free this */ - ExFreePool(IoInterrupt); + ExFreePoolWithTag(IoInterrupt, TAG_KINTERRUPT); } else { @@ -163,7 +163,7 @@ IoDisconnectInterrupt(PKINTERRUPT InterruptObject) } /* Free the I/O Interrupt */ - ExFreePool(IoInterrupt); + ExFreePool(IoInterrupt); // ExFreePoolWithTag(IoInterrupt, TAG_KINTERRUPT); } /* EOF */ diff --git a/reactos/ntoskrnl/mm/ARM3/drvmgmt.c b/reactos/ntoskrnl/mm/ARM3/drvmgmt.c index 756c127b90e..a50eddbf680 100644 --- a/reactos/ntoskrnl/mm/ARM3/drvmgmt.c +++ b/reactos/ntoskrnl/mm/ARM3/drvmgmt.c @@ -200,7 +200,7 @@ Cleanup: // // Free the table if we failed and return status // - if (DriverThunks) ExFreePool(DriverThunks); + if (DriverThunks) ExFreePoolWithTag(DriverThunks, 'tVmM'); return Status; } diff --git a/reactos/ntoskrnl/mm/ARM3/expool.c b/reactos/ntoskrnl/mm/ARM3/expool.c index 9e76a1a06d8..a5f081843e3 100644 --- a/reactos/ntoskrnl/mm/ARM3/expool.c +++ b/reactos/ntoskrnl/mm/ARM3/expool.c @@ -358,7 +358,7 @@ ExpComputeHashForTag(IN ULONG Tag, // Finally, AND with the bucket mask to generate a valid index/bucket into // the table // - ULONGLONG Result = 40543 * Tag; + ULONGLONG Result = (ULONGLONG)40543 * Tag; return (ULONG)BucketMask & ((ULONG)Result ^ (Result >> 32)); } @@ -1185,7 +1185,7 @@ ExGetPoolTagInfo(IN PSYSTEM_POOLTAG_INFORMATION SystemInformation, // // Free the "Generic DPC" temporary buffer, return the buffer length and status // - ExFreePool(Buffer); + ExFreePoolWithTag(Buffer, 'ofnI'); if (ReturnLength) *ReturnLength = CurrentLength; return Status; } diff --git a/reactos/ntoskrnl/mm/ARM3/mminit.c b/reactos/ntoskrnl/mm/ARM3/mminit.c index a5e6f9c4d99..06db17afc6d 100644 --- a/reactos/ntoskrnl/mm/ARM3/mminit.c +++ b/reactos/ntoskrnl/mm/ARM3/mminit.c @@ -1172,7 +1172,7 @@ MmFreeLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) KeFlushCurrentTb(); /* Free our run structure */ - ExFreePool(Buffer); + ExFreePoolWithTag(Buffer, 'lMmM'); } VOID diff --git a/reactos/ntoskrnl/mm/ARM3/pagfault.c b/reactos/ntoskrnl/mm/ARM3/pagfault.c index 0ddb40e6b4f..aa45a70c97b 100644 --- a/reactos/ntoskrnl/mm/ARM3/pagfault.c +++ b/reactos/ntoskrnl/mm/ARM3/pagfault.c @@ -663,7 +663,7 @@ MiResolveTransitionFault(IN PVOID FaultingAddress, ASSERT(Pfn1->u3.e1.ReadInProgress == 0); /* Windows checks there's some free pages and this isn't an in-page error */ - ASSERT(MmAvailablePages >= 0); + ASSERT(MmAvailablePages > 0); ASSERT(Pfn1->u4.InPageError == 0); /* ReactOS checks for this */ diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index b1c50a2d92d..ae5d496e9f9 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -118,7 +118,11 @@ MiCreatePebOrTeb(IN PEPROCESS Process, Base, &Parent); /* Bail out, if still nothing free was found */ - if (Result == TableFoundNode) return STATUS_NO_MEMORY; + if (Result == TableFoundNode) + { + ExFreePoolWithTag(Vad, 'ldaV'); + return STATUS_NO_MEMORY; + } } /* Validate that it came from the VAD ranges */ @@ -1857,6 +1861,7 @@ MiSessionCreateInternal(OUT PULONG SessionId) { /* We ran out of session IDs, we should expand */ DPRINT1("Too many sessions created. Expansion not yet supported\n"); + ExFreePoolWithTag(PageTables, 'tHmM'); return STATUS_NO_MEMORY; } diff --git a/reactos/ntoskrnl/mm/ARM3/sysldr.c b/reactos/ntoskrnl/mm/ARM3/sysldr.c index d10e6a202d8..3f42163b590 100644 --- a/reactos/ntoskrnl/mm/ARM3/sysldr.c +++ b/reactos/ntoskrnl/mm/ARM3/sysldr.c @@ -1,11 +1,11 @@ /* -* PROJECT: ReactOS Kernel -* LICENSE: BSD - See COPYING.ARM in the top level directory -* FILE: ntoskrnl/mm/ARM3/sysldr.c -* PURPOSE: Contains the Kernel Loader (SYSLDR) for loading PE files. -* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) -* ReactOS Portable Systems Group -*/ + * PROJECT: ReactOS Kernel + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: ntoskrnl/mm/ARM3/sysldr.c + * PURPOSE: Contains the Kernel Loader (SYSLDR) for loading PE files. + * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) + * ReactOS Portable Systems Group + */ /* INCLUDES *******************************************************************/ @@ -2179,9 +2179,13 @@ MiInitializeLoadedModuleList(IN PLOADER_PARAMETER_BLOCK LoaderBlock) NewEntry->FullDllName.Buffer = ExAllocatePoolWithTag(PagedPool, LdrEntry->FullDllName.MaximumLength + - sizeof(UNICODE_NULL), + sizeof(UNICODE_NULL), TAG_LDR_WSTR); - if (!NewEntry->FullDllName.Buffer) return FALSE; + if (!NewEntry->FullDllName.Buffer) + { + ExFreePoolWithTag(NewEntry, TAG_MODULE_OBJECT); + return FALSE; + } /* Set the base name */ NewEntry->BaseDllName.Buffer = (PVOID)(NewEntry + 1); @@ -3436,3 +3440,4 @@ MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName) return ProcAddress; } +/* EOF */ diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index 52bd39a9ef7..3e248ad4ba9 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -1099,7 +1099,7 @@ MiDoPoolCopy(IN PEPROCESS SourceProcess, // // Check if we had allocated pool // - if (HavePoolAddress) ExFreePool(PoolAddress); + if (HavePoolAddress) ExFreePoolWithTag(PoolAddress, 'VmRw'); // // Check if we failed during the probe @@ -1160,7 +1160,7 @@ MiDoPoolCopy(IN PEPROCESS SourceProcess, // // Check if we had allocated pool // - if (HavePoolAddress) ExFreePool(PoolAddress); + if (HavePoolAddress) ExFreePoolWithTag(PoolAddress, 'VmRw'); // // All bytes read diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index fec489a90dc..2dd55ee15ca 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -1761,17 +1761,12 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace, Region->Protect, &NewPage, 1); - if (!NT_SUCCESS(Status)) - { - DPRINT("MmCreateVirtualMapping failed, not out of memory\n"); - KeBugCheck(MEMORY_MANAGEMENT); - return(Status); - } - if (!NT_SUCCESS(Status)) - { - DPRINT1("Unable to create virtual mapping\n"); - KeBugCheck(MEMORY_MANAGEMENT); - } + if (!NT_SUCCESS(Status)) + { + DPRINT1("MmCreateVirtualMapping failed, unable to create virtual mapping, not out of memory\n"); + KeBugCheck(MEMORY_MANAGEMENT); + return(Status); + } /* * Unshare the old page. @@ -3786,7 +3781,7 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, if(ImageSectionObject->Segments != NULL) ExFreePool(ImageSectionObject->Segments); - ExFreePool(ImageSectionObject); + ExFreePoolWithTag(ImageSectionObject, TAG_MM_SECTION_SEGMENT); ObDereferenceObject(Section); ObDereferenceObject(FileObject); return(StatusExeFmt); -- 2.17.1