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