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 <qiandongyan@loongson.cn>
This commit is contained in:
Dongyan Qian
2025-06-11 11:58:13 +08:00
committed by mergify[bot]
parent ddacfa238a
commit 108757b613

View File

@@ -188,11 +188,12 @@ RedfishConfigCommonStop (
&NumberOfHandles, &NumberOfHandles,
&HandleBuffer &HandleBuffer
); );
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { if (Status == EFI_NOT_FOUND) {
return EFI_SUCCESS;
} else if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Status = EFI_SUCCESS;
for (Index = 0; Index < NumberOfHandles; Index++) { for (Index = 0; Index < NumberOfHandles; Index++) {
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
@@ -208,6 +209,8 @@ RedfishConfigCommonStop (
} }
} }
gBS->FreePool (HandleBuffer);
return Status; return Status;
} }
@@ -272,4 +275,6 @@ RedfishConfigHandlerInitialization (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
gBS->FreePool (HandleBuffer);
} }