The structure instance retunred by ToStructure() must be deallocated properly.
Cc: Abner Chang <abner.ch...@amd.com> Cc: Igor Kulchytskyy <ig...@ami.com> Cc: Nickle Wang <nick...@nvidia.com> Signed-off-by: Mike Maslenkin <mike.maslen...@gmail.com> --- .../v1_13_0/Common/ComputerSystemCommon.c | 25 +++++++++++++------ .../v1_5_0/Common/ComputerSystemCommon.c | 25 +++++++++++++------ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c index df22a1c90c46..4795e4d6c6eb 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c @@ -263,7 +263,7 @@ ProvisioningComputerSystemProperties ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Status)); - return Status; + goto ON_RELEASE; } ComputerSystemCs = ComputerSystem->ComputerSystem; @@ -365,7 +365,7 @@ ProvisioningComputerSystemProperties ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status)); - return Status; + goto ON_RELEASE; } if (PropertyChanged) { @@ -374,10 +374,14 @@ ProvisioningComputerSystemProperties ( if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable properties from ResultJson.\n", __func__)); *ResultJson = NULL; - return Status; + goto ON_RELEASE; } } + Status = EFI_SUCCESS; + +ON_RELEASE: + // // Release resource. // @@ -393,10 +397,17 @@ ProvisioningComputerSystemProperties ( DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder, ArraySize); } - JsonStructProtocol->DestoryStructure ( - JsonStructProtocol, - (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemEmpty - ); + if (ComputerSystemEmpty != NULL) { + JsonStructProtocol->DestoryStructure ( + JsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemEmpty + ); + } + + if (EFI_ERROR (Status)) { + return Status; + } + return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); } diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c index c383cad59029..2d257e01da2b 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c @@ -793,7 +793,7 @@ ProvisioningComputerSystemProperties ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Status)); - return Status; + goto ON_RELEASE; } ComputerSystemCs = ComputerSystem->ComputerSystem; @@ -1235,7 +1235,7 @@ ProvisioningComputerSystemProperties ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status)); - return Status; + goto ON_RELEASE; } if (PropertyChanged) { @@ -1244,10 +1244,14 @@ ProvisioningComputerSystemProperties ( if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable properties from ResultJson.\n", __func__)); *ResultJson = NULL; - return Status; + goto ON_RELEASE; } } + Status = EFI_SUCCESS; + +ON_RELEASE: + // // Release resource. // @@ -1263,10 +1267,17 @@ ProvisioningComputerSystemProperties ( DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder, ArraySize); } - JsonStructProtocol->DestoryStructure ( - JsonStructProtocol, - (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemEmpty - ); + if (ComputerSystemEmpty != NULL) { + JsonStructProtocol->DestoryStructure ( + JsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemEmpty + ); + } + + if (EFI_ERROR (Status)) { + return Status; + } + return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); } -- 2.32.0 (Apple Git-132) -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116567): https://edk2.groups.io/g/devel/message/116567 Mute This Topic: https://groups.io/mt/104841894/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-