From: Yao, Jiewen Date: Wed, 25 Nov 2015 04:05:49 +0000 (+0000) Subject: Uninstall LoadedImage protocol if SMM driver returns error and is unloaded. X-Git-Tag: edk2-stable201903~8520 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=02f02b16e268d4e62676b69d2eaedf18e792d002 Uninstall LoadedImage protocol if SMM driver returns error and is unloaded. Original code does not uninstall LoadedImage protocol if SMM driver returns error and is unloaded. It causes a wrong LoadedImage protocol existing in system. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Yao, Jiewen" Reviewed-by: "Zeng, Star" Reviewed-by: "Kinney, Michael D" git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18936 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c index 81e8a0dc82..cbaf549066 100644 --- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c +++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c @@ -881,6 +881,20 @@ SmmDispatcher ( if (EFI_ERROR(Status)){ UnregisterSmramProfileImage (DriverEntry, TRUE); SmmFreePages(DriverEntry->ImageBuffer, DriverEntry->NumberOfPage); + // + // Uninstall LoadedImage + // + Status = gBS->UninstallProtocolInterface ( + DriverEntry->ImageHandle, + &gEfiLoadedImageProtocolGuid, + DriverEntry->LoadedImage + ); + if (!EFI_ERROR (Status)) { + if (DriverEntry->LoadedImage->FilePath != NULL) { + gBS->FreePool (DriverEntry->LoadedImage->FilePath); + } + gBS->FreePool (DriverEntry->LoadedImage); + } } REPORT_STATUS_CODE_WITH_EXTENDED_DATA (