diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c index 5f52afa0fe..a9e06be1ad 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -390,8 +390,16 @@ MmCommunicationInitialize ( MmGuidedEventNotify, mGuidedEventGuid[Index], mGuidedEventGuid[Index], &mGuidedEvent[Index]); ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + while (Index-- > 0) { + gBS->CloseEvent (mGuidedEvent[Index]); + } + goto UninstallProtocol; + } } + return EFI_SUCCESS; +UninstallProtocol: gBS->UninstallProtocolInterface ( mMmCommunicateHandle, &gEfiMmCommunicationProtocolGuid,