https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cf1a95a588e077341c6c1…
commit cf1a95a588e077341c6c1a3540a8f895949065c2
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Thu Jun 17 17:41:37 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Mon Jun 28 10:20:57 2021 +0200
[NTOS:EX] Do not ignore PsCreateSystemThread return value
CORE-17637
---
ntoskrnl/ex/work.c | 40 ++++++++++++++++++++++++++--------------
1 file changed, 26 insertions(+), 14 deletions(-)
diff --git a/ntoskrnl/ex/work.c b/ntoskrnl/ex/work.c
index a10a4878b42..9dec3405b76 100644
--- a/ntoskrnl/ex/work.c
+++ b/ntoskrnl/ex/work.c
@@ -254,6 +254,7 @@ ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType,
HANDLE hThread;
ULONG Context;
KPRIORITY Priority;
+ NTSTATUS Status;
/* Check if this is going to be a dynamic thread */
Context = WorkQueueType;
@@ -262,13 +263,19 @@ ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType,
if (Dynamic) Context |= EX_DYNAMIC_WORK_THREAD;
/* Create the System Thread */
- PsCreateSystemThread(&hThread,
- THREAD_ALL_ACCESS,
- NULL,
- NULL,
- NULL,
- ExpWorkerThreadEntryPoint,
- UlongToPtr(Context));
+ Status = PsCreateSystemThread(&hThread,
+ THREAD_ALL_ACCESS,
+ NULL,
+ NULL,
+ NULL,
+ ExpWorkerThreadEntryPoint,
+ UlongToPtr(Context));
+ if (!NT_SUCCESS(Status))
+ {
+ /* Well... */
+ DPRINT1("Failed to create worker thread: 0x%08x\n", Status);
+ return;
+ }
/* If the thread is dynamic */
if (Dynamic)
@@ -519,6 +526,7 @@ ExpInitializeWorkerThreads(VOID)
HANDLE ThreadHandle;
PETHREAD Thread;
ULONG i;
+ NTSTATUS Status;
/* Setup the stack swap support */
ExInitializeFastMutex(&ExpWorkerSwapinMutex);
@@ -576,13 +584,17 @@ ExpInitializeWorkerThreads(VOID)
ExpCreateWorkerThread(HyperCriticalWorkQueue, FALSE);
/* Create the balance set manager thread */
- PsCreateSystemThread(&ThreadHandle,
- THREAD_ALL_ACCESS,
- NULL,
- 0,
- NULL,
- ExpWorkerThreadBalanceManager,
- NULL);
+ Status = PsCreateSystemThread(&ThreadHandle,
+ THREAD_ALL_ACCESS,
+ NULL,
+ 0,
+ NULL,
+ ExpWorkerThreadBalanceManager,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
+ }
/* Get a pointer to it for the shutdown process */
ObReferenceObjectByHandle(ThreadHandle,