Just found "if (!Buffer)" doesn't follow EDK2 coding style. I changed to "if (Buffer == NULL) {" in final merge PR.
> -----Original Message----- > From: Gerd Hoffmann <kra...@redhat.com> > Sent: Friday, March 10, 2023 8:49 PM > To: devel@edk2.groups.io > Cc: Ni, Ray <ray...@intel.com>; Oliver Steffen <ostef...@redhat.com>; > Gerd Hoffmann <kra...@redhat.com>; Kumar, Rahul R > <rahul.r.ku...@intel.com>; Pawel Polawski <ppola...@redhat.com>; Dong, > Eric <eric.d...@intel.com> > Subject: [PATCH 2/2] 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 <kra...@redhat.com> > --- > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > index 55a9f79da8eb..2e41df1f1074 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) { > + 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))); > } > -- > 2.39.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101539): https://edk2.groups.io/g/devel/message/101539 Mute This Topic: https://groups.io/mt/97518449/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-