summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorJiewen Yao <jiewen.yao@intel.com>2017-03-27 23:01:02 +0800
committerJiewen Yao <jiewen.yao@intel.com>2017-03-31 08:22:53 +0800
commit251779fca719bf9ea00505ee7629c08b452c150d (patch)
tree5e5118e4f9808a975026b9b910160d5e8bf54337 /MdeModulePkg/Core
parent072060a6f81b3e43473b9e5dcba7049ad9de4b18 (diff)
downloadedk2-platforms-251779fca719bf9ea00505ee7629c08b452c150d.tar.xz
MdeModulePkg/SmmCore: Fix memory leak on Profile unregistered.
Issue reported at bugzillar 445. Cc: Jeff Fan <jeff.fan@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c7
1 files changed, 6 insertions, 1 deletions
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)) {