From d2c243e1991273df3fa6037c6bb675ac1c7551f4 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Tue, 8 May 2012 03:10:37 +0000 Subject: [PATCH] Fix the potential issue that NULL pointer may be referred in LoadImage(). Signed-off-by: Liming Gao Reviewed-by: Rui Sun git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13293 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/Image/Image.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index e51a9fe174..9a143284e7 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -1353,6 +1353,7 @@ CoreLoadImage ( { EFI_STATUS Status; UINT64 Tick; + EFI_HANDLE Handle; Tick = 0; PERF_CODE ( @@ -1372,8 +1373,16 @@ CoreLoadImage ( EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION | EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION ); - PERF_START (*ImageHandle, "LoadImage:", NULL, Tick); - PERF_END (*ImageHandle, "LoadImage:", NULL, 0); + Handle = NULL; + if (!EFI_ERROR (Status)) { + // + // ImageHandle will be valid only Status is success. + // + Handle = *ImageHandle; + } + + PERF_START (Handle, "LoadImage:", NULL, Tick); + PERF_END (Handle, "LoadImage:", NULL, 0); return Status; }