mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
da770255f2
commit
75b046c3d4
|
@ -17,6 +17,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
// Module Globals
|
// Module Globals
|
||||||
//
|
//
|
||||||
|
|
||||||
|
SPIN_LOCK mUnloadImageLock;
|
||||||
|
|
||||||
LOADED_IMAGE_PRIVATE_DATA *mCurrentImage = NULL;
|
LOADED_IMAGE_PRIVATE_DATA *mCurrentImage = NULL;
|
||||||
|
|
||||||
LOAD_PE32_IMAGE_PRIVATE_DATA mLoadPe32PrivateData = {
|
LOAD_PE32_IMAGE_PRIVATE_DATA mLoadPe32PrivateData = {
|
||||||
|
@ -137,6 +139,11 @@ CoreInitializeImageServices (
|
||||||
|
|
||||||
mCurrentImage = Image;
|
mCurrentImage = Image;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize spin lock
|
||||||
|
//
|
||||||
|
InitializeSpinLock (&mUnloadImageLock);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fill in DXE globals
|
// Fill in DXE globals
|
||||||
//
|
//
|
||||||
|
@ -1362,13 +1369,14 @@ CoreUnloadImage (
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
LOADED_IMAGE_PRIVATE_DATA *Image;
|
LOADED_IMAGE_PRIVATE_DATA *Image;
|
||||||
EFI_TPL OldTpl;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Prevent possible reentrance to this function
|
// Prevent possible reentrance to this function
|
||||||
// for the same ImageHandle
|
// for the same ImageHandle
|
||||||
//
|
//
|
||||||
OldTpl = CoreRaiseTpl (TPL_NOTIFY);
|
if (!AcquireSpinLockOrFail (&mUnloadImageLock)) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
Image = CoreLoadedImageInfo (ImageHandle);
|
Image = CoreLoadedImageInfo (ImageHandle);
|
||||||
if (Image == NULL ) {
|
if (Image == NULL ) {
|
||||||
|
@ -1404,7 +1412,7 @@ CoreUnloadImage (
|
||||||
}
|
}
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
CoreRestoreTpl (OldTpl);
|
ReleaseSpinLock (&mUnloadImageLock);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue