From 108757b613620e8406f32e5aa2e52df8d115d61f Mon Sep 17 00:00:00 2001 From: Dongyan Qian Date: Wed, 11 Jun 2025 11:58:13 +0800 Subject: [PATCH] RedfishPkg/RedfishConfigHandler: Free handle buffers Fix memory leaks by adding missing FreePool calls: free handle buffers in Stop and initialization routines. REF:https://uefi.org/sites/default/files/resources/UEFI_Spec_Final_2.11.pdf Chapter 7.3.15: "Services - Boot Services.LocateHandleBuffer": It is the caller's responsibility to call the Boot Service.FreePool when the caller no longer requires the contents of Buffer. Signed-off-by: Dongyan Qian --- .../RedfishConfigHandler/RedfishConfigHandlerCommon.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerCommon.c b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerCommon.c index bc1ba59835..f6c8c3db36 100644 --- a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerCommon.c +++ b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerCommon.c @@ -188,11 +188,12 @@ RedfishConfigCommonStop ( &NumberOfHandles, &HandleBuffer ); - if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { + if (Status == EFI_NOT_FOUND) { + return EFI_SUCCESS; + } else if (EFI_ERROR (Status)) { return Status; } - Status = EFI_SUCCESS; for (Index = 0; Index < NumberOfHandles; Index++) { Status = gBS->HandleProtocol ( HandleBuffer[Index], @@ -208,6 +209,8 @@ RedfishConfigCommonStop ( } } + gBS->FreePool (HandleBuffer); + return Status; } @@ -272,4 +275,6 @@ RedfishConfigHandlerInitialization ( ); ASSERT_EFI_ERROR (Status); } + + gBS->FreePool (HandleBuffer); }