From 0b80c293c364ef7efea793b8cc2658fcfda3eaf7 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Fri, 27 Sep 2024 16:42:21 -0400 Subject: [PATCH] VanGoghBoard/FspsWrapperPeim: Prevent null pointer dereference Return from FspsWrapperInitDispatchMode() if a buffer allocation fails instead of attempting to dereference the pointer. Signed-off-by: Michael Kubacki --- .../Fsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Platform/AMD/VanGoghBoard/Override/edk2/Fsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c b/Platform/AMD/VanGoghBoard/Override/edk2/Fsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c index e6a589bcb57..008769cbc1d 100644 --- a/Platform/AMD/VanGoghBoard/Override/edk2/Fsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c +++ b/Platform/AMD/VanGoghBoard/Override/edk2/Fsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c @@ -542,13 +542,20 @@ FspsWrapperInitDispatchMode ( if (BootMode != BOOT_ON_S3_RESUME) { MeasurementExcludedFvPpi = AllocatePool (sizeof (*MeasurementExcludedFvPpi)); - ASSERT (MeasurementExcludedFvPpi != NULL); + if (MeasurementExcludedFvPpi == NULL) { + ASSERT (MeasurementExcludedFvPpi != NULL); + return EFI_OUT_OF_RESOURCES; + } MeasurementExcludedFvPpi->Count = 1; MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspsBaseAddressInMemory); MeasurementExcludedFvPpi->Fv[0].FvLength = PcdGet32 (PcdFspsRegionSize); MeasurementExcludedPpiList = AllocatePool (sizeof (*MeasurementExcludedPpiList)); - ASSERT (MeasurementExcludedPpiList != NULL); + if (MeasurementExcludedPpiList == NULL) { + ASSERT (MeasurementExcludedPpiList != NULL); + FreePool (MeasurementExcludedFvPpi); + return EFI_OUT_OF_RESOURCES; + } MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; MeasurementExcludedPpiList->Guid = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid; MeasurementExcludedPpiList->Ppi = MeasurementExcludedFvPpi;