summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
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)) {