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 <[email protected]>
Cc: Igor Kulchytskyy <[email protected]>
Cc: Nickle Wang <[email protected]>
Signed-off-by: Mike Maslenkin <[email protected]>
Reviewed-by: Abner Chang <[email protected]>
Reviewed-by: Nickle Wang <[email protected]>
  • Loading branch information
ghbaccount authored and changab committed Mar 14, 2024
1 parent 3077cab commit 0499a77
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 0499a77

Please sign in to comment.