Author: dchapyshev
Date: Wed Sep 2 15:02:30 2009
New Revision: 42980
URL:
http://svn.reactos.org/svn/reactos?rev=42980&view=rev
Log:
- Add missed checks of memory allocation failures
Modified:
trunk/reactos/ntoskrnl/cc/view.c
trunk/reactos/ntoskrnl/fstub/disksup.c
trunk/reactos/ntoskrnl/io/iomgr/driver.c
trunk/reactos/ntoskrnl/io/iomgr/file.c
trunk/reactos/ntoskrnl/io/iomgr/iofunc.c
trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c
trunk/reactos/ntoskrnl/ke/profobj.c
trunk/reactos/ntoskrnl/mm/marea.c
trunk/reactos/ntoskrnl/mm/region.c
trunk/reactos/ntoskrnl/mm/section.c
trunk/reactos/ntoskrnl/ob/oblink.c
trunk/reactos/ntoskrnl/ps/kill.c
trunk/reactos/ntoskrnl/se/semgr.c
Modified: trunk/reactos/ntoskrnl/cc/view.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=429…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -1325,6 +1325,10 @@
}
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);
Modified: trunk/reactos/ntoskrnl/fstub/disksup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fstub/disksup.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/fstub/disksup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/fstub/disksup.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -452,6 +452,8 @@
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 @@
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++)
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -1007,6 +1007,7 @@
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;
Modified: trunk/reactos/ntoskrnl/io/iomgr/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/file.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/file.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/file.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -2872,7 +2872,7 @@
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
-
+ /* Ignore exception */
}
_SEH2_END;
Modified: trunk/reactos/ntoskrnl/io/iomgr/iofunc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iofunc.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/iofunc.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/iofunc.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -1015,6 +1015,12 @@
{
/* 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 @@
{
/* 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 @@
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 @@
{
/* 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 @@
{
/* 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 @@
{
/* 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 @@
{
/* Use local event */
Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_IO);
+ if (!Event)
+ {
+ ObDereferenceObject(FileObject);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
LocalEvent = TRUE;
}
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpnoti…
==============================================================================
--- trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -61,6 +61,11 @@
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 @@
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 @@
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));
Modified: trunk/reactos/ntoskrnl/ke/profobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/profobj.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/profobj.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/profobj.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -62,6 +62,7 @@
SourceBuffer = ExAllocatePoolWithTag(NonPagedPool,
sizeof(KPROFILE_SOURCE_OBJECT),
'forP');
+ if (!SourceBuffer) return;
RtlZeroMemory(SourceBuffer, sizeof(KPROFILE_SOURCE_OBJECT));
/* Raise to PROFILE_LEVEL */
Modified: trunk/reactos/ntoskrnl/mm/marea.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=42…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -1006,7 +1006,9 @@
sizeof(MEMORY_AREA),
TAG_MAREA);
}
-
+
+ if (!MemoryArea) return STATUS_NO_MEMORY;
+
RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA));
MemoryArea->Type = Type;
MemoryArea->StartingAddress = *BaseAddress;
Modified: trunk/reactos/ntoskrnl/mm/region.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/region.c?rev=4…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/region.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/region.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -245,6 +245,8 @@
Region = ExAllocatePoolWithTag(NonPagedPool, sizeof(MM_REGION),
TAG_MM_REGION);
+ if (!Region) return;
+
Region->Type = Type;
Region->Protect = Protect;
Region->Length = Length;
Modified: trunk/reactos/ntoskrnl/mm/section.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -2756,6 +2756,10 @@
Buffer = ExAllocatePoolWithTag(PagedPool,
BufferSize,
'rXmM');
+ if (!Buffer)
+ {
+ KeBugCheck(MEMORY_MANAGEMENT);
+ }
UsedSize = 0;
Modified: trunk/reactos/ntoskrnl/ob/oblink.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/oblink.c?rev=4…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/oblink.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ob/oblink.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -123,6 +123,7 @@
PWSTR NewTargetPath;
ULONG LengthUsed, MaximumLength;
NTSTATUS Status;
+ PAGED_CODE();
/* Assume failure */
*NextObject = NULL;
@@ -169,6 +170,7 @@
NewTargetPath = ExAllocatePoolWithTag(NonPagedPool,
MaximumLength,
TAG_SYMLINK_TTARGET);
+ if (!NewTargetPath) return STATUS_INSUFFICIENT_RESOURCES;
}
else
{
Modified: trunk/reactos/ntoskrnl/ps/kill.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/kill.c?rev=429…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/kill.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/kill.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -969,6 +969,7 @@
/* 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;
Modified: trunk/reactos/ntoskrnl/se/semgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/se/semgr.c?rev=42…
==============================================================================
--- trunk/reactos/ntoskrnl/se/semgr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/se/semgr.c [iso-8859-1] Wed Sep 2 15:02:30 2009
@@ -86,6 +86,8 @@
NTAPI
SepInitializationPhase0(VOID)
{
+ PAGED_CODE();
+
ExpInitLuid();
if (!SepInitSecurityIDs()) return FALSE;
if (!SepInitDACLs()) return FALSE;