diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2024-09-27 16:46:07 -0400 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-10-28 16:10:09 +0000 |
commit | 4de80843a74475aef3ac47127cec0e52c1f5aa46 (patch) | |
tree | eb87bc405c8ffd14b189cda930389ba2b72b7376 /IntelFsp2WrapperPkg/FspsWrapperPeim | |
parent | ea59e39c85637aef6b0bc2e3307036bf296124c0 (diff) | |
download | edk2-4de80843a74475aef3ac47127cec0e52c1f5aa46.tar.gz |
IntelFsp2WrapperPkg: Prevent null pointer dereference
Return from `FspsWrapperInitDispatchMode()` if a buffer allocation
fails instead of attempting to dereference the pointer.
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Diffstat (limited to 'IntelFsp2WrapperPkg/FspsWrapperPeim')
-rw-r--r-- | IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c index 1d4dd60577..62b5e45348 100644 --- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c +++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c @@ -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;
|