diff options
author | lzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-11-12 01:33:41 +0000 |
---|---|---|
committer | lzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-11-12 01:33:41 +0000 |
commit | e0d216f6a88dab3007d7633dc40e3c81d29536b9 (patch) | |
tree | 55e313758509c175dda4be5cfb6b7a889e3ca1b3 /MdeModulePkg/Universal/Acpi | |
parent | 6b13aa602aa1f44743d40691baff2714d842c550 (diff) | |
download | edk2-e0d216f6a88dab3007d7633dc40e3c81d29536b9.zip edk2-e0d216f6a88dab3007d7633dc40e3c81d29536b9.tar.gz edk2-e0d216f6a88dab3007d7633dc40e3c81d29536b9.tar.bz2 |
Free the buffer allocated by GetSectionFromAnyFv() when exit, and add Error Status Check for InstallProtocolInterface(), GetSectionFromAnyFv() return.
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13933 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Acpi')
-rw-r--r-- | MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c index e671164..d5698d4 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c @@ -235,7 +235,7 @@ BootScriptExecutorEntryPoint ( // This is the first-time loaded by DXE core. reload itself to NVS mem
//
//
- // A workarouond: Here we install a dummy handle
+ // A workaround: Here we install a dummy handle
//
NewImageHandle = NULL;
Status = gBS->InstallProtocolInterface (
@@ -244,6 +244,7 @@ BootScriptExecutorEntryPoint ( EFI_NATIVE_INTERFACE,
NULL
);
+ ASSERT_EFI_ERROR (Status);
Status = GetSectionFromAnyFv (
&gEfiCallerIdGuid,
@@ -252,15 +253,14 @@ BootScriptExecutorEntryPoint ( (VOID **) &Buffer,
&BufferSize
);
+ ASSERT_EFI_ERROR (Status);
ImageContext.Handle = Buffer;
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
//
// Get information about the image being loaded
//
Status = PeCoffLoaderGetImageInfo (&ImageContext);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ ASSERT_EFI_ERROR (Status);
Pages = EFI_SIZE_TO_PAGES(BufferSize + ImageContext.SectionAlignment);
FfsBuffer = 0xFFFFFFFF;
Status = gBS->AllocatePages (
@@ -269,9 +269,7 @@ BootScriptExecutorEntryPoint ( Pages,
&FfsBuffer
);
- if (EFI_ERROR (Status)) {
- return EFI_OUT_OF_RESOURCES;
- }
+ ASSERT_EFI_ERROR (Status);
ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)FfsBuffer;
//
// Align buffer on section boundry
@@ -282,30 +280,26 @@ BootScriptExecutorEntryPoint ( // Load the image to our new buffer
//
Status = PeCoffLoaderLoadImage (&ImageContext);
- if (EFI_ERROR (Status)) {
- gBS->FreePages (FfsBuffer, Pages);
- return Status;
- }
+ ASSERT_EFI_ERROR (Status);
//
// Relocate the image in our new buffer
//
Status = PeCoffLoaderRelocateImage (&ImageContext);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Free the buffer allocated by ReadSection since the image has been relocated in the new buffer
+ //
+ gBS->FreePool (Buffer);
- if (EFI_ERROR (Status)) {
- PeCoffLoaderUnloadImage (&ImageContext);
- gBS->FreePages (FfsBuffer, Pages);
- return Status;
- }
//
// Flush the instruction cache so the image data is written before we execute it
//
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) (NewImageHandle, SystemTable);
- if (EFI_ERROR (Status)) {
- gBS->FreePages (FfsBuffer, Pages);
- return Status;
- }
+ ASSERT_EFI_ERROR (Status);
+
//
// Additional step for BootScript integrity
// Save BootScriptExecutor image
@@ -334,9 +328,7 @@ BootScriptExecutorEntryPoint ( Pages,
&BootScriptExecutorBuffer
);
- if (EFI_ERROR (Status)) {
- return EFI_OUT_OF_RESOURCES;
- }
+ ASSERT_EFI_ERROR (Status);
EfiBootScriptExecutorVariable = (BOOT_SCRIPT_EXECUTOR_VARIABLE *)(UINTN)BootScriptExecutorBuffer;
EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint = (UINTN) S3BootScriptExecutorEntryFunction ;
|