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>
This commit is contained in:
Jiewen Yao 2017-03-27 23:01:02 +08:00
parent 072060a6f8
commit 251779fca7
1 changed files with 6 additions and 1 deletions

View File

@ -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)) {