From ffe3109d37939a70b0e742fbdb6955b9c5b92473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Fri, 18 Nov 2022 18:08:21 +0100 Subject: [PATCH] [NTOS:KD] Handle work-buffer allocation failure in KdpDebugLogInit. It can be ignored in KdpScreenInit. --- ntoskrnl/kd/kdio.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c index 1b0cd821383..8c0ca1825ad 100644 --- a/ntoskrnl/kd/kdio.c +++ b/ntoskrnl/kd/kdio.c @@ -237,7 +237,14 @@ KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, else if (BootPhase == 1) { /* Allocate a buffer for debug log */ - KdpDebugBuffer = ExAllocatePool(NonPagedPool, KdpBufferSize); + KdpDebugBuffer = ExAllocatePoolZero(NonPagedPool, + KdpBufferSize, + TAG_KDBG); + if (!KdpDebugBuffer) + { + KdpDebugMode.File = FALSE; + return; + } KdpFreeBytes = KdpBufferSize; /* Initialize spinlock */ @@ -519,8 +526,10 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, /* Allocate a buffer for dmesg log buffer. +1 for terminating null, * see kdbp_cli.c:KdbpCmdDmesg()/2 */ - KdpDmesgBuffer = ExAllocatePool(NonPagedPool, KdpDmesgBufferSize + 1); - RtlZeroMemory(KdpDmesgBuffer, KdpDmesgBufferSize + 1); + KdpDmesgBuffer = ExAllocatePoolZero(NonPagedPool, + KdpDmesgBufferSize + 1, + TAG_KDBG); + /* Ignore failure if KdpDmesgBuffer is NULL */ KdpDmesgFreeBytes = KdpDmesgBufferSize; KdbDmesgTotalWritten = 0;