From 3840c35e34d1c992268092b6366e26f2acc55a75 Mon Sep 17 00:00:00 2001 From: Du Lin Date: Tue, 12 Mar 2024 10:54:30 +0800 Subject: IntelFsp2WrapperPkg: Error handling of FspmWrapperInit() REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4701 The error handling of FspmWrapperInit() is limited to ASSERT statements only, which only works in debug builds, but not in release builds. Fix the issue by enhancing the error handling of FspmWrapperInit() to cover both debug builds and release builds. Cc: Ashraf Ali S Cc: Chasel Chiu Cc: Chen Gang C Cc: Duggapu Chinni B Cc: Nate DeSimone Cc: Ray Ni Cc: Star Zeng Cc: Susovan Mohapatra Cc: Ted Kuo Signed-off-by: Du Lin Reviewed-by: Ashraf Ali S Reviewed-by: Chen Gang C Reviewed-by: Ray Ni --- IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c index ba0c742fea..7f1deb9542 100644 --- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c +++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c @@ -197,12 +197,20 @@ FspmWrapperInit ( MeasurementExcludedFvPpi = AllocatePool (sizeof (*MeasurementExcludedFvPpi)); ASSERT (MeasurementExcludedFvPpi != NULL); + if (MeasurementExcludedFvPpi == NULL) { + return EFI_OUT_OF_RESOURCES; + } + MeasurementExcludedFvPpi->Count = 1; MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspmBaseAddress); MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspmBaseAddress))->FvLength; MeasurementExcludedPpiList = AllocatePool (sizeof (*MeasurementExcludedPpiList)); ASSERT (MeasurementExcludedPpiList != NULL); + if (MeasurementExcludedPpiList == NULL) { + return EFI_OUT_OF_RESOURCES; + } + MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; MeasurementExcludedPpiList->Guid = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid; MeasurementExcludedPpiList->Ppi = MeasurementExcludedFvPpi; -- cgit v1.2.3