summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2017-08-11 11:02:39 +0800
committerStar Zeng <star.zeng@intel.com>2017-08-14 16:45:59 +0800
commitd9af5af8d96866821e50882fbd45686c28aaafed (patch)
tree981af83ad0e5ed51239f0358e0948aff5da9ba98 /MdeModulePkg/Core
parent0024172d909ec73a9ce9ffdfc9fdd4382080e110 (diff)
downloadedk2-d9af5af8d96866821e50882fbd45686c28aaafed.tar.gz
edk2-d9af5af8d96866821e50882fbd45686c28aaafed.tar.bz2
edk2-d9af5af8d96866821e50882fbd45686c28aaafed.zip
MdeModulePkg DxeCore: Fix double free pages on LoadImage failure path
https://bugzilla.tianocore.org/show_bug.cgi?id=667 reported there is double free pages on LoadImage failure path. CoreLoadPeImage() ... return EFI_SUCCESS; Done: // // Free memory. // if (DstBufAlocated) { CoreFreePages (Image->ImageContext.ImageAddress, Image->NumberOfPages); } ... CoreUnloadAndCloseImage() ... if ((Image->ImageBasePage != 0) && FreePage) { CoreFreePages (Image->ImageBasePage, Image->NumberOfPages); } ... This patch is to follow the suggestion at https://lists.01.org/pipermail/edk2-devel/2017-August/013112.html to set Image->ImageContext.ImageAddress and Image->ImageBasePage to 0 after the free in CoreLoadPeImage(). Cc: Liming Gao <liming.gao@intel.com> Cc: Andrew Fish <afish@apple.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/Dxe/Image/Image.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index 03e979a604..4e22aa6dc7 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -788,6 +788,8 @@ Done:
if (DstBufAlocated) {
CoreFreePages (Image->ImageContext.ImageAddress, Image->NumberOfPages);
+ Image->ImageContext.ImageAddress = 0;
+ Image->ImageBasePage = 0;
}
if (Image->ImageContext.FixupData != NULL) {