From 18fcd6a70c87badd6342873d9a034acf4695283d Mon Sep 17 00:00:00 2001 From: lgao4 Date: Wed, 11 Mar 2009 02:53:15 +0000 Subject: [PATCH] Add check to the allocated pool. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7861 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c | 8 ++++++++ MdeModulePkg/Core/Pei/FwVol/FwVol.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c index 02b8914ff8..9b7b166a99 100644 --- a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c +++ b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c @@ -513,6 +513,10 @@ ProduceFVBProtocolOnBuffer ( // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH // FvbDev->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate); + if (FvbDev->DevicePath == NULL) { + FreePool (FvbDev); + return EFI_OUT_OF_RESOURCES; + } ((FV_MEMMAP_DEVICE_PATH *) FvbDev->DevicePath)->MemMapDevPath.StartingAddress = BaseAddress; ((FV_MEMMAP_DEVICE_PATH *) FvbDev->DevicePath)->MemMapDevPath.EndingAddress = BaseAddress + FwVolHeader->FvLength - 1; } else { @@ -520,6 +524,10 @@ ProduceFVBProtocolOnBuffer ( // FV contains extension header, then produce MEDIA_FW_VOL_DEVICE_PATH // FvbDev->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate); + if (FvbDev->DevicePath == NULL) { + FreePool (FvbDev); + return EFI_OUT_OF_RESOURCES; + } CopyGuid ( &((FV_PIWG_DEVICE_PATH *)FvbDev->DevicePath)->FvDevPath.FvName, (GUID *)(UINTN)(BaseAddress + FwVolHeader->ExtHeaderOffset) diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c index d4162057e7..2e78e51936 100644 --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -935,7 +935,7 @@ ProcessFvFile ( BuildFvHob ( (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart, FvImageInfo.FvSize - ); + ); // // Makes the encapsulated volume show up in DXE phase to skip processing of -- 2.39.2