]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg DxeCore: Avoid the closed event to be signaled wrongly
authorStar Zeng <star.zeng@intel.com>
Wed, 27 Jan 2016 10:15:15 +0000 (10:15 +0000)
committerlzeng14 <lzeng14@Edk2>
Wed, 27 Jan 2016 10:15:15 +0000 (10:15 +0000)
Signal a closed event will still invoke the event notification function,
it could only be exposed when no the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED
bit set in PcdDebugPropertyMask.

For example:
  gBS->CreateEvent (
                EVT_NOTIFY_SIGNAL,
                TPL_CALLBACK,
                CallbackFun,
                NULL,
                &Event
                );
  gBS->CloseEvent (Event);
  gBS->SignalEvent (Event);      <- CallbackFun still be invoked

Although the case to signal a closed event is abnormal, the code could
still be enhanced to avoid it.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Thomas Palmer <thomas.palmer@hpe.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19754 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Event/Event.c

index 34b34ac62f7c4c2564adaa301a48b1a16d41cdd6..01715ec3ca7d7625639d16d7905952dbdc2b0c29 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Event support functions implemented in this file.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, 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
@@ -769,6 +769,11 @@ CoreCloseEvent (
     CoreUnregisterProtocolNotify (Event);\r
   }\r
 \r
+  //\r
+  // To avoid the Event to be signalled wrongly after closed,\r
+  // clear the Signature of Event before free pool.\r
+  //\r
+  Event->Signature = 0;\r
   Status = CoreFreePool (Event);\r
   ASSERT_EFI_ERROR (Status);\r
 \r