X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FCore%2FDxe%2FImage%2FImage.c;h=3696400072e6f6be71090466699a6ef877228256;hp=e9541f7f9d3490ef8dc929d742f43d8ca1b1c611;hb=b06af5d71ec9fc353b9433a26fc55d14077f7cde;hpb=1cc8ee7861a59532700a6fd1255689576eda0f52 diff --git a/EdkModulePkg/Core/Dxe/Image/Image.c b/EdkModulePkg/Core/Dxe/Image/Image.c index e9541f7f9d..3696400072 100644 --- a/EdkModulePkg/Core/Dxe/Image/Image.c +++ b/EdkModulePkg/Core/Dxe/Image/Image.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2006, Intel Corporation +Copyright (c) 2006 - 2007, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -1218,10 +1218,18 @@ Returns: --*/ { LOADED_IMAGE_PRIVATE_DATA *Image; + EFI_TPL OldTpl; + // + // Prevent possible reentrance to this function + // for the same ImageHandle + // + OldTpl = CoreRaiseTpl (EFI_TPL_NOTIFY); + Image = CoreLoadedImageInfo (ImageHandle); if (Image == NULL_HANDLE) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } if (!Image->Started) { @@ -1229,7 +1237,8 @@ Returns: // The image has not been started so just free its resources // CoreUnloadAndCloseImage (Image, TRUE); - return EFI_SUCCESS; + Status = EFI_SUCCESS; + goto Done; } // @@ -1237,7 +1246,8 @@ Returns: // if (Image != mCurrentImage) { DEBUG ((EFI_D_LOAD|EFI_D_ERROR, "Exit: Image is not exitable image\n")); - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } // @@ -1252,11 +1262,13 @@ Returns: Image->ExitDataSize = ExitDataSize; Image->ExitData = CoreAllocateBootServicesPool (Image->ExitDataSize); if (Image->ExitData == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = EFI_OUT_OF_RESOURCES; + goto Done; } CopyMem (Image->ExitData, ExitData, Image->ExitDataSize); } + CoreRestoreTpl (OldTpl); // // return to StartImage // @@ -1266,7 +1278,10 @@ Returns: // If we return from LongJump, then it is an error // ASSERT (FALSE); - return EFI_ACCESS_DENIED; + Status = EFI_ACCESS_DENIED; +Done: + CoreRestoreTpl (OldTpl); + return Status; } @@ -1296,13 +1311,21 @@ Returns: { EFI_STATUS Status; LOADED_IMAGE_PRIVATE_DATA *Image; + EFI_TPL OldTpl; + // + // Prevent possible reentrance to this function + // for the same ImageHandle + // + OldTpl = CoreRaiseTpl (EFI_TPL_NOTIFY); + Image = CoreLoadedImageInfo (ImageHandle); if (Image == NULL ) { // // The image handle is not valid // - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } if (Image->Started) { @@ -1329,6 +1352,8 @@ Returns: CoreUnloadAndCloseImage (Image, TRUE); } +Done: + CoreRestoreTpl (OldTpl); return Status; }