mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
- Add missed checks of memory allocation failures
svn path=/trunk/; revision=42980
This commit is contained in:
parent
733c8b092d
commit
8954edb33c
13 changed files with 74 additions and 2 deletions
|
@ -1325,6 +1325,10 @@ CcInitView(VOID)
|
|||
}
|
||||
|
||||
Buffer = ExAllocatePool(NonPagedPool, CI_CACHESEG_MAPPING_REGION_SIZE / (PAGE_SIZE * 8));
|
||||
if (!Buffer)
|
||||
{
|
||||
KeBugCheck(CACHE_MANAGER);
|
||||
}
|
||||
|
||||
RtlInitializeBitMap(&CiCacheSegMappingRegionAllocMap, Buffer, CI_CACHESEG_MAPPING_REGION_SIZE / PAGE_SIZE);
|
||||
RtlClearAllBits(&CiCacheSegMappingRegionAllocMap);
|
||||
|
|
|
@ -452,6 +452,8 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
|
|||
PartialInformation = (PKEY_VALUE_PARTIAL_INFORMATION)ExAllocatePool(PagedPool,
|
||||
sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(REG_DISK_MOUNT_INFO));
|
||||
|
||||
if (!Buffer1 || !Buffer2 || !PartialInformation) return;
|
||||
|
||||
DiskMountInfo = (PREG_DISK_MOUNT_INFO) PartialInformation->Data;
|
||||
|
||||
/* Open or Create the 'MountedDevices' key */
|
||||
|
@ -526,6 +528,14 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
|
|||
goto end_assign_disks;
|
||||
LayoutArray = ExAllocatePool(NonPagedPool,
|
||||
ConfigInfo->DiskCount * sizeof(PDRIVE_LAYOUT_INFORMATION));
|
||||
if (!LayoutArray)
|
||||
{
|
||||
ExFreePool(PartialInformation);
|
||||
ExFreePool(Buffer2);
|
||||
ExFreePool(Buffer1);
|
||||
if (hKey) ZwClose(hKey);
|
||||
}
|
||||
|
||||
RtlZeroMemory(LayoutArray,
|
||||
ConfigInfo->DiskCount * sizeof(PDRIVE_LAYOUT_INFORMATION));
|
||||
for (i = 0; i < ConfigInfo->DiskCount; i++)
|
||||
|
|
|
@ -1007,6 +1007,7 @@ IopUnloadDriver(PUNICODE_STRING DriverServiceName, BOOLEAN UnloadPnpDrivers)
|
|||
ObjectName.Length = (wcslen(Start) + 8) * sizeof(WCHAR);
|
||||
ObjectName.MaximumLength = ObjectName.Length + sizeof(WCHAR);
|
||||
ObjectName.Buffer = ExAllocatePool(PagedPool, ObjectName.MaximumLength);
|
||||
if (!ObjectName.Buffer) return STATUS_INSUFFICIENT_RESOURCES;
|
||||
wcscpy(ObjectName.Buffer, L"\\Driver\\");
|
||||
memcpy(ObjectName.Buffer + 8, Start, ObjectName.Length - 8 * sizeof(WCHAR));
|
||||
ObjectName.Buffer[ObjectName.Length/sizeof(WCHAR)] = 0;
|
||||
|
|
|
@ -2872,7 +2872,7 @@ NtCancelIoFile(IN HANDLE FileHandle,
|
|||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
/* Ignore exception */
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
|
|
|
@ -1015,6 +1015,12 @@ NtFlushBuffersFile(IN HANDLE FileHandle,
|
|||
{
|
||||
/* Use local event */
|
||||
Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_IO);
|
||||
if (!Event)
|
||||
{
|
||||
/* We failed */
|
||||
ObDereferenceObject(FileObject);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
|
||||
LocalEvent = TRUE;
|
||||
}
|
||||
|
@ -1548,6 +1554,7 @@ NtQueryDirectoryFile(IN HANDLE FileHandle,
|
|||
{
|
||||
/* Allocate an MDL */
|
||||
Mdl = IoAllocateMdl(FileInformation, Length, FALSE, TRUE, Irp);
|
||||
if (!Mdl) ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES);
|
||||
MmProbeAndLockPages(Mdl, PreviousMode, IoWriteAccess);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
|
@ -1636,6 +1643,7 @@ NtQueryInformationFile(IN HANDLE FileHandle,
|
|||
PVOID NormalContext;
|
||||
KIRQL OldIrql;
|
||||
IO_STATUS_BLOCK KernelIosb;
|
||||
PAGED_CODE();
|
||||
IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
|
||||
|
||||
/* Check if we're called from user mode */
|
||||
|
@ -1749,6 +1757,11 @@ NtQueryInformationFile(IN HANDLE FileHandle,
|
|||
{
|
||||
/* Use local event */
|
||||
Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_IO);
|
||||
if (!Event)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
|
||||
LocalEvent = TRUE;
|
||||
}
|
||||
|
@ -2666,6 +2679,11 @@ NtUnlockFile(IN HANDLE FileHandle,
|
|||
{
|
||||
/* Use local event */
|
||||
Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_IO);
|
||||
if (!Event)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
|
||||
LocalEvent = TRUE;
|
||||
}
|
||||
|
@ -3102,6 +3120,11 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
|
|||
{
|
||||
/* Use local event */
|
||||
Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_IO);
|
||||
if (!Event)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
|
||||
LocalEvent = TRUE;
|
||||
}
|
||||
|
@ -3263,6 +3286,11 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
|
|||
{
|
||||
/* Use local event */
|
||||
Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_IO);
|
||||
if (!Event)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
|
||||
LocalEvent = TRUE;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,11 @@ IopNotifyPlugPlayNotification(
|
|||
PagedPool,
|
||||
sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION),
|
||||
TAG_PNP_NOTIFY);
|
||||
if (!NotificationInfos)
|
||||
{
|
||||
KeReleaseGuardedMutex(&PnpNotifyListLock);
|
||||
return;
|
||||
}
|
||||
NotificationInfos->Version = 1;
|
||||
NotificationInfos->Size = sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION);
|
||||
RtlCopyMemory(&NotificationInfos->Event, Event, sizeof(GUID));
|
||||
|
@ -75,6 +80,11 @@ IopNotifyPlugPlayNotification(
|
|||
PagedPool,
|
||||
sizeof(HWPROFILE_CHANGE_NOTIFICATION),
|
||||
TAG_PNP_NOTIFY);
|
||||
if (!NotificationInfos)
|
||||
{
|
||||
KeReleaseGuardedMutex(&PnpNotifyListLock);
|
||||
return;
|
||||
}
|
||||
NotificationInfos->Version = 1;
|
||||
NotificationInfos->Size = sizeof(HWPROFILE_CHANGE_NOTIFICATION);
|
||||
RtlCopyMemory(&NotificationInfos->Event, Event, sizeof(GUID));
|
||||
|
@ -87,6 +97,11 @@ IopNotifyPlugPlayNotification(
|
|||
PagedPool,
|
||||
sizeof(TARGET_DEVICE_REMOVAL_NOTIFICATION),
|
||||
TAG_PNP_NOTIFY);
|
||||
if (!NotificationInfos)
|
||||
{
|
||||
KeReleaseGuardedMutex(&PnpNotifyListLock);
|
||||
return;
|
||||
}
|
||||
NotificationInfos->Version = 1;
|
||||
NotificationInfos->Size = sizeof(TARGET_DEVICE_REMOVAL_NOTIFICATION);
|
||||
RtlCopyMemory(&NotificationInfos->Event, Event, sizeof(GUID));
|
||||
|
|
|
@ -62,6 +62,7 @@ KeStartProfile(PKPROFILE Profile,
|
|||
SourceBuffer = ExAllocatePoolWithTag(NonPagedPool,
|
||||
sizeof(KPROFILE_SOURCE_OBJECT),
|
||||
'forP');
|
||||
if (!SourceBuffer) return;
|
||||
RtlZeroMemory(SourceBuffer, sizeof(KPROFILE_SOURCE_OBJECT));
|
||||
|
||||
/* Raise to PROFILE_LEVEL */
|
||||
|
|
|
@ -1006,7 +1006,9 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
|
|||
sizeof(MEMORY_AREA),
|
||||
TAG_MAREA);
|
||||
}
|
||||
|
||||
|
||||
if (!MemoryArea) return STATUS_NO_MEMORY;
|
||||
|
||||
RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA));
|
||||
MemoryArea->Type = Type;
|
||||
MemoryArea->StartingAddress = *BaseAddress;
|
||||
|
|
|
@ -245,6 +245,8 @@ MmInitializeRegion(PLIST_ENTRY RegionListHead, ULONG Length, ULONG Type,
|
|||
|
||||
Region = ExAllocatePoolWithTag(NonPagedPool, sizeof(MM_REGION),
|
||||
TAG_MM_REGION);
|
||||
if (!Region) return;
|
||||
|
||||
Region->Type = Type;
|
||||
Region->Protect = Protect;
|
||||
Region->Length = Length;
|
||||
|
|
|
@ -2756,6 +2756,10 @@ ExeFmtpReadFile(IN PVOID File,
|
|||
Buffer = ExAllocatePoolWithTag(PagedPool,
|
||||
BufferSize,
|
||||
'rXmM');
|
||||
if (!Buffer)
|
||||
{
|
||||
KeBugCheck(MEMORY_MANAGEMENT);
|
||||
}
|
||||
|
||||
UsedSize = 0;
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ ObpParseSymbolicLink(IN PVOID ParsedObject,
|
|||
PWSTR NewTargetPath;
|
||||
ULONG LengthUsed, MaximumLength;
|
||||
NTSTATUS Status;
|
||||
PAGED_CODE();
|
||||
|
||||
/* Assume failure */
|
||||
*NextObject = NULL;
|
||||
|
@ -169,6 +170,7 @@ ObpParseSymbolicLink(IN PVOID ParsedObject,
|
|||
NewTargetPath = ExAllocatePoolWithTag(NonPagedPool,
|
||||
MaximumLength,
|
||||
TAG_SYMLINK_TTARGET);
|
||||
if (!NewTargetPath) return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -969,6 +969,7 @@ PspTerminateThreadByPointer(IN PETHREAD Thread,
|
|||
|
||||
/* Allocate the APC */
|
||||
Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC);
|
||||
if (!Apc) return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
/* Set the Terminated Flag */
|
||||
Flags = Thread->CrossThreadFlags | CT_TERMINATED_BIT;
|
||||
|
|
|
@ -86,6 +86,8 @@ BOOLEAN
|
|||
NTAPI
|
||||
SepInitializationPhase0(VOID)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
ExpInitLuid();
|
||||
if (!SepInitSecurityIDs()) return FALSE;
|
||||
if (!SepInitDACLs()) return FALSE;
|
||||
|
|
Loading…
Reference in a new issue