summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-01 08:10:49 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-01 08:10:49 +0000
commit75b046c3d4aca166de580f5b80c42a14fcbd60eb (patch)
tree8eaf49b6bbf48843361778e3820ac5930bb78105 /MdeModulePkg
parentda770255f25f67ab9fa8a92be33c2fad6c0654d9 (diff)
downloadedk2-platforms-75b046c3d4aca166de580f5b80c42a14fcbd60eb.tar.xz
Using Spin lock instead of using RaiseTpl() to prevent UnloadImage() re-entrance.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5600 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Dxe/Image/Image.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index dbb662519f..477eaa3417 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -17,6 +17,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// Module Globals
//
+SPIN_LOCK mUnloadImageLock;
+
LOADED_IMAGE_PRIVATE_DATA *mCurrentImage = NULL;
LOAD_PE32_IMAGE_PRIVATE_DATA mLoadPe32PrivateData = {
@@ -138,6 +140,11 @@ CoreInitializeImageServices (
mCurrentImage = Image;
//
+ // Initialize spin lock
+ //
+ InitializeSpinLock (&mUnloadImageLock);
+
+ //
// Fill in DXE globals
//
gDxeCoreImageHandle = Image->Handle;
@@ -1362,13 +1369,14 @@ CoreUnloadImage (
{
EFI_STATUS Status;
LOADED_IMAGE_PRIVATE_DATA *Image;
- EFI_TPL OldTpl;
//
// Prevent possible reentrance to this function
// for the same ImageHandle
//
- OldTpl = CoreRaiseTpl (TPL_NOTIFY);
+ if (!AcquireSpinLockOrFail (&mUnloadImageLock)) {
+ return EFI_UNSUPPORTED;
+ }
Image = CoreLoadedImageInfo (ImageHandle);
if (Image == NULL ) {
@@ -1404,7 +1412,7 @@ CoreUnloadImage (
}
Done:
- CoreRestoreTpl (OldTpl);
+ ReleaseSpinLock (&mUnloadImageLock);
return Status;
}