From 85fcc4774c3604857804355a679618ab73ce30e6 Mon Sep 17 00:00:00 2001 From: Mikhail Krichanov Date: Tue, 12 Mar 2024 13:56:29 +0300 Subject: [PATCH] Ring3: Added FreeProtocolsList(). --- MdeModulePkg/Core/Dxe/DxeMain.h | 6 ++++++ MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 2 ++ MdeModulePkg/Core/Dxe/SysCall/BootServices.c | 20 +++++++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 3e72054103..f8fd68f866 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2736,4 +2736,10 @@ InitializeRing3 ( IN LOADED_IMAGE_PRIVATE_DATA *Image ); +VOID +EFIAPI +FreeProtocolsList ( + VOID + ); + #endif diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index d217b6d915..2eaec6f4d5 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -850,6 +850,8 @@ CoreExitBootServices ( RING3_INTERFACES_PAGES ); + FreeProtocolsList (); + return Status; } diff --git a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c index c861e05797..dadb6cd12a 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c +++ b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c @@ -7,9 +7,7 @@ #include "DxeMain.h" #include "SupportedProtocols.h" -// -// TODO: Free LIST in ExitBootServices -// + LIST_ENTRY mProtocolsHead = INITIALIZE_LIST_HEAD_VARIABLE (mProtocolsHead); typedef struct { @@ -29,6 +27,22 @@ CallInstallMultipleProtocolInterfaces ( IN VOID *Function ); +VOID +EFIAPI +FreeProtocolsList ( + VOID + ) +{ + LIST_ENTRY *Link; + INTERFACE *Protocol; + + for (Link = mProtocolsHead.BackLink; Link != &mProtocolsHead; Link = mProtocolsHead.BackLink) { + Protocol = BASE_CR (Link, INTERFACE, Link); + RemoveEntryList (Link); + FreePool (Protocol); + } +} + STATIC EFI_STATUS EFIAPI