Skip to content

Commit

Permalink
IntelFsp2WrapperPkg: 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 authored and mergify[bot] committed Oct 28, 2024
1 parent ea59e39 commit 4de8084
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,22 @@ FspsWrapperInitDispatchMode (
EFI_PEI_PPI_DESCRIPTOR *MeasurementExcludedPpiList;

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 (PcdFspsBaseAddress);
MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength;

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 4de8084

Please sign in to comment.