Skip to content

Commit

Permalink
VanGoghBoard/FspsWrapperPeim: Prevent null pointer dereference
Browse files Browse the repository at this point in the history
Return from FspsWrapperInitDispatchMode() if a buffer allocation
fails instead of attempting to dereference the pointer.

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki committed Jan 28, 2025
1 parent 649cc10 commit 0b80c29
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0b80c29

Please sign in to comment.