From: Jiewen Yao Date: Mon, 27 Mar 2017 15:01:02 +0000 (+0800) Subject: MdeModulePkg/SmmCore: Fix memory leak on Profile unregistered. X-Git-Tag: edk2-stable201903~4279 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=251779fca719bf9ea00505ee7629c08b452c150d;ds=inline MdeModulePkg/SmmCore: Fix memory leak on Profile unregistered. Issue reported at bugzillar 445. Cc: Jeff Fan Cc: Feng Tian Cc: Star Zeng Cc: Bret Barkelew Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao Reviewed-by: Jeff Fan --- diff --git a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c index 1e36039dd4..ad3b54ace4 100644 --- a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c +++ b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c @@ -1186,7 +1186,9 @@ SmiHandlerProfileRegisterHandler ( SmiEntry = SmmCoreFindHardwareSmiEntry (HandlerGuid, TRUE); if (SmiEntry == NULL) { - FreePool (SmiHandler->Context); + if (SmiHandler->Context != NULL) { + FreePool (SmiHandler->Context); + } FreePool (SmiHandler); return EFI_OUT_OF_RESOURCES; } @@ -1277,6 +1279,9 @@ SmiHandlerProfileUnregisterHandler ( SmiHandler = TargetSmiHandler; RemoveEntryList (&SmiHandler->Link); + if (SmiHandler->Context != NULL) { + FreePool (SmiHandler->Context); + } FreePool (SmiHandler); if (IsListEmpty (&SmiEntry->SmiHandlers)) {