From 02f02b16e268d4e62676b69d2eaedf18e792d002 Mon Sep 17 00:00:00 2001 From: "Yao, Jiewen" Date: Wed, 25 Nov 2015 04:05:49 +0000 Subject: [PATCH] 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 --- MdeModulePkg/Core/PiSmmCore/Dispatcher.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 ( -- 2.39.2