From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: wei6.xu@intel.com) Received: from mga06.intel.com (mga06.intel.com []) by groups.io with SMTP; Thu, 25 Jul 2019 20:11:07 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2019 20:11:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,309,1559545200"; d="scan'208";a="170497789" Received: from shwdeopenpsi174.ccr.corp.intel.com ([10.239.157.39]) by fmsmga008.fm.intel.com with ESMTP; 25 Jul 2019 20:11:06 -0700 From: "Xu, Wei6" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao Subject: [edk2-devel][Patch 2/3] MdePkg/UefiDebugLibDebugPortProtocol: Add destructor to CloseEvent Date: Fri, 26 Jul 2019 11:10:54 +0800 Message-Id: <20190726031055.10020-3-wei6.xu@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20190726031055.10020-1-wei6.xu@intel.com> References: <20190726031055.10020-1-wei6.xu@intel.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2012 When driver is unloaded, the ExitBootSerivesEvent must be closed at the same time. Otherwise exception will occur when ExitBootServices. Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Wei6 Xu --- .../DebugLibConstructor.c | 23 ++++++++++++++++++++++ .../UefiDebugLibDebugPortProtocol.inf | 1 + 2 files changed, 24 insertions(+) diff --git a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLibConstructor.c b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLibConstructor.c index de60d339a8..6ea0912f2b 100644 --- a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLibConstructor.c +++ b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLibConstructor.c @@ -73,5 +73,28 @@ DxeDebugLibConstructor( &mExitBootServicesEvent ); return EFI_SUCCESS; } + +/** + The destructor closes Exit Boot Services Event. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The destructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +DxeDebugLibDestructor( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + if (mExitBootServicesEvent != NULL) { + SystemTable->BootServices->CloseEvent (mExitBootServicesEvent); + } + + return EFI_SUCCESS; +} diff --git a/MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf b/MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf index 10a8f2a857..ff09a12ce4 100644 --- a/MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf +++ b/MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf @@ -20,10 +20,11 @@ MODULE_TYPE = UEFI_DRIVER VERSION_STRING = 1.0 LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER CONSTRUCTOR = DxeDebugLibConstructor + DESTRUCTOR = DxeDebugLibDestructor # # VALID_ARCHITECTURES = IA32 X64 EBC # -- 2.16.2.windows.1