MdeModulePkg DxeCore: Avoid the closed event to be signaled wrongly

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
This commit is contained in:
Star Zeng 2016-01-27 10:15:15 +00:00 committed by lzeng14
parent 5955601cdf
commit 1a4acc1136
1 changed files with 6 additions and 1 deletions

View File

@ -1,7 +1,7 @@
/** @file
UEFI Event support functions implemented in this file.
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -769,6 +769,11 @@ CoreCloseEvent (
CoreUnregisterProtocolNotify (Event);
}
//
// To avoid the Event to be signalled wrongly after closed,
// clear the Signature of Event before free pool.
//
Event->Signature = 0;
Status = CoreFreePool (Event);
ASSERT_EFI_ERROR (Status);