summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2023-03-10 20:48:49 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-22 04:04:57 +0000
commit4f441d024bee7e1a6438737b58e4b0b6856b3eab (patch)
tree8c84f49b1c68d8b51d19940a3e77c14c19dbb8c7 /UefiCpuPkg
parent2e71876081706bef2d43a82ece3bb078706ee4cd (diff)
downloadedk2-4f441d024bee7e1a6438737b58e4b0b6856b3eab.tar.gz
edk2-4f441d024bee7e1a6438737b58e4b0b6856b3eab.tar.bz2
edk2-4f441d024bee7e1a6438737b58e4b0b6856b3eab.zip
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 <kraxel@redhat.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c6
1 files changed, 6 insertions, 0 deletions
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)));
}