From 28bc6992400d56351d36b26f0841fbfcb1ea2fd4 Mon Sep 17 00:00:00 2001 From: "Xu, Wei6" Date: Fri, 26 Jul 2019 11:10:55 +0800 Subject: MdePkg/UefiDebugLibStdErr: Add destructor to CloseEvent 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 Reviewed-by: Liming Gao --- .../UefiDebugLibStdErr/DebugLibConstructor.c | 23 ++++++++++++++++++++++ .../UefiDebugLibStdErr/UefiDebugLibStdErr.inf | 1 + 2 files changed, 24 insertions(+) (limited to 'MdePkg') diff --git a/MdePkg/Library/UefiDebugLibStdErr/DebugLibConstructor.c b/MdePkg/Library/UefiDebugLibStdErr/DebugLibConstructor.c index 8005370372..ed73f92818 100644 --- a/MdePkg/Library/UefiDebugLibStdErr/DebugLibConstructor.c +++ b/MdePkg/Library/UefiDebugLibStdErr/DebugLibConstructor.c @@ -75,3 +75,26 @@ DxeDebugLibConstructor( 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/UefiDebugLibStdErr/UefiDebugLibStdErr.inf b/MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf index deaa3427f6..11f7594626 100644 --- a/MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf +++ b/MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf @@ -22,6 +22,7 @@ LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER CONSTRUCTOR = DxeDebugLibConstructor + DESTRUCTOR = DxeDebugLibDestructor # # VALID_ARCHITECTURES = IA32 X64 EBC -- cgit v1.2.3