]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Event/Event.c
MdeModulePkg: Remove event from protocol database only if registered
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Event / Event.c
index a8c4c34d83c9f0a98a6ab655b75db48eea9346cd..34b34ac62f7c4c2564adaa301a48b1a16d41cdd6 100644 (file)
@@ -2,6 +2,7 @@
   UEFI Event support functions implemented in this file.\r
 \r
 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -477,7 +478,7 @@ CoreCreateEventInternal (
   IEvent->NotifyContext  = (VOID *)NotifyContext;\r
   if (EventGroup != NULL) {\r
     CopyGuid (&IEvent->EventGroup, EventGroup);\r
-    IEvent->ExFlag = TRUE;\r
+    IEvent->ExFlag |= EVT_EXFLAG_EVENT_GROUP;\r
   }\r
 \r
   *Event = IEvent;\r
@@ -554,7 +555,7 @@ CoreSignalEvent (
     // If signalling type is a notify function, queue it\r
     //\r
     if ((Event->Type & EVT_NOTIFY_SIGNAL) != 0) {\r
-      if (Event->ExFlag) {\r
+      if ((Event->ExFlag & EVT_EXFLAG_EVENT_GROUP) != 0) {\r
         //\r
         // The CreateEventEx() style requires all members of the Event Group\r
         //  to be signaled.\r
@@ -764,7 +765,9 @@ CoreCloseEvent (
   //\r
   // If the event is registered on a protocol notify, then remove it from the protocol database\r
   //\r
-  CoreUnregisterProtocolNotify (Event);\r
+  if ((Event->ExFlag & EVT_EXFLAG_EVENT_PROTOCOL_NOTIFICATION) != 0) {\r
+    CoreUnregisterProtocolNotify (Event);\r
+  }\r
 \r
   Status = CoreFreePool (Event);\r
   ASSERT_EFI_ERROR (Status);\r