Skip to content

Commit

Permalink
RedfishClientPkg: fix memory leak
Browse files Browse the repository at this point in the history
The structure instance retunred by ToStructure() must be deallocated
properly.

Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
  • Loading branch information
ghbaccount committed Mar 12, 2024
1 parent cb80dc3 commit fc317f6
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,20 @@ RedfishIdentifyResource (
ComputerSystemCs = ComputerSystem->ComputerSystem;

if (IS_EMPTY_STRING (ComputerSystemCs->UUID)) {
return FALSE;
Status = EFI_NOT_FOUND;
goto ON_RELEASE;
}

Status = AsciiStrToGuid (ComputerSystemCs->UUID, &ResourceUuid);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, fail to get resource UUID: %r\n", __func__, Status));
return FALSE;
goto ON_RELEASE;
}

Status = NetLibGetSystemGuid (&SystemUuid);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, fail to get system UUID from SMBIOS: %r\n", __func__, Status));
return FALSE;
goto ON_RELEASE;
}

DEBUG ((REDFISH_DEBUG_TRACE, "%a, Identify: System: %g Resource: %g\n", __func__, &SystemUuid, &ResourceUuid));
Expand All @@ -92,6 +93,8 @@ RedfishIdentifyResource (
Status = EFI_UNSUPPORTED;
}

ON_RELEASE:

mJsonStructProtocol->DestoryStructure (
mJsonStructProtocol,
(EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem
Expand Down

0 comments on commit fc317f6

Please sign in to comment.