From 4f441d024bee7e1a6438737b58e4b0b6856b3eab Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 10 Mar 2023 20:48:49 +0800 Subject: UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling ASSERT() is not proper handling of allocation failures, it gets compiled out on RELEASE builds. Print a message and enter dead loop instead. Signed-off-by: Gerd Hoffmann Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'UefiCpuPkg') diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 55a9f79da8..cf69161caa 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -879,6 +879,12 @@ PiCpuSmmEntry ( // BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize * (mMaxNumberOfCpus - 1)); Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB); + if (Buffer == NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate %d pages.\n", BufferPages)); + CpuDeadLoop (); + return EFI_OUT_OF_RESOURCES; + } + ASSERT (Buffer != NULL); DEBUG ((DEBUG_INFO, "New Allcoated SMRAM SaveState Buffer (0x%08x, 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE (BufferPages))); } -- cgit v1.2.3