PrmPkg/DxePrmContextBufferLib: Free handle buffers after LocateHandleBuffer
Fix memory leaks by adding missing FreePool calls: cleanup HandleBuffer in GetModuleContextBuffers. 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:
committed by
mergify[bot]
parent
ef516ea82d
commit
ddacfa238a
@@ -104,37 +104,41 @@ GetModuleContextBuffers (
|
|||||||
&HandleCount,
|
&HandleCount,
|
||||||
&HandleBuffer
|
&HandleBuffer
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
return Status;
|
||||||
Status = gBS->HandleProtocol (
|
}
|
||||||
HandleBuffer[Index],
|
|
||||||
&gPrmConfigProtocolGuid,
|
for (Index = 0; Index < HandleCount; Index++) {
|
||||||
(VOID **)&PrmConfigProtocol
|
Status = gBS->HandleProtocol (
|
||||||
);
|
HandleBuffer[Index],
|
||||||
ASSERT_EFI_ERROR (Status);
|
&gPrmConfigProtocolGuid,
|
||||||
if (EFI_ERROR (Status) || (PrmConfigProtocol == NULL)) {
|
(VOID **)&PrmConfigProtocol
|
||||||
continue;
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
if (EFI_ERROR (Status) || (PrmConfigProtocol == NULL)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GuidSearchType == ByModuleGuid) {
|
||||||
|
if (CompareGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, Guid)) {
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
" %a %a: Found a PRM configuration protocol for PRM module %g.\n",
|
||||||
|
_DBGMSGID_,
|
||||||
|
__func__,
|
||||||
|
Guid
|
||||||
|
));
|
||||||
|
|
||||||
|
*PrmModuleContextBuffers = &PrmConfigProtocol->ModuleContextBuffers;
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (GuidSearchType == ByModuleGuid) {
|
Status = FindContextBufferInModuleBuffers (Guid, &PrmConfigProtocol->ModuleContextBuffers, &PrmContextBuffer);
|
||||||
if (CompareGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, Guid)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
DEBUG ((
|
*PrmModuleContextBuffers = &PrmConfigProtocol->ModuleContextBuffers;
|
||||||
DEBUG_INFO,
|
Status = EFI_SUCCESS;
|
||||||
" %a %a: Found a PRM configuration protocol for PRM module %g.\n",
|
goto Exit;
|
||||||
_DBGMSGID_,
|
|
||||||
__func__,
|
|
||||||
Guid
|
|
||||||
));
|
|
||||||
|
|
||||||
*PrmModuleContextBuffers = &PrmConfigProtocol->ModuleContextBuffers;
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Status = FindContextBufferInModuleBuffers (Guid, &PrmConfigProtocol->ModuleContextBuffers, &PrmContextBuffer);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
*PrmModuleContextBuffers = &PrmConfigProtocol->ModuleContextBuffers;
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,7 +151,12 @@ GetModuleContextBuffers (
|
|||||||
Guid
|
Guid
|
||||||
));
|
));
|
||||||
|
|
||||||
return EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
|
|
||||||
|
Exit:
|
||||||
|
gBS->FreePool (HandleBuffer);
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user