Reviewed-by: Nickle Wang <nick...@nvidia.com>

Regards,
Nickle

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Mike
> Maslenkin via groups.io
> Sent: Sunday, March 10, 2024 6:42 PM
> To: devel@edk2.groups.io
> Cc: Mike Maslenkin <mike.maslen...@gmail.com>; Abner Chang
> <abner.ch...@amd.com>; Igor Kulchytskyy <ig...@ami.com>; Nickle Wang
> <nick...@nvidia.com>
> Subject: [edk2-devel] [PATCH 1/4][edk2-redfish-client] RedfishClientPkg: fix
> memory leak
> 
> External email: Use caution opening links or attachments
> 
> 
> This patch fixes leak of EFI_REDFISH_COMPUTERSYSTEMCOLLECTION instance
> on error path.
> 
> 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>
> ---
>  .../ComputerSystemCollectionDxe.c                    | 12 +++++++++---
>  .../MemoryCollectionDxe/MemoryCollectionDxe.c        | 11 ++++++++---
>  2 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git
> a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCo
> llectionDxe.c
> b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCo
> llectionDxe.c
> index 55a6d07dbf2e..3deefa824629 100644
> ---
> a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCo
> llectionDxe.c
> +++ b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSyst
> +++ emCollectionDxe.c
> @@ -174,11 +174,13 @@ HandleCollectionResource (
>    CollectionCs = Collection->ComputerSystemCollection;
> 
> 
> 
>    if (*CollectionCs->Membersodata_count == 0) {
> 
> -    return EFI_NOT_FOUND;
> 
> +    Status = EFI_NOT_FOUND;
> 
> +    goto ON_RELEASE;
> 
>    }
> 
> 
> 
>    if (IsLinkEmpty (&CollectionCs->Members)) {
> 
> -    return EFI_NOT_FOUND;
> 
> +    Status = EFI_NOT_FOUND;
> 
> +    goto ON_RELEASE;
> 
>    }
> 
> 
> 
>    List = GetFirstLink (&CollectionCs->Members);
> 
> @@ -206,12 +208,16 @@ HandleCollectionResource (
>      List = GetNextLink (&CollectionCs->Members, List);
> 
>    }
> 
> 
> 
> +  Status = EFI_SUCCESS;
> 
> +
> 
> +ON_RELEASE:
> 
> +
> 
>    //
> 
>    // Release resource.
> 
>    //
> 
>    Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtocol,
> (EFI_REST_JSON_STRUCTURE_HEADER *)Collection);
> 
> 
> 
> -  return EFI_SUCCESS;
> 
> +  return Status;
> 
>  }
> 
> 
> 
>  EFI_STATUS
> 
> diff --git
> a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
> index d963fb52ad37..38f28f902715 100644
> --- a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
> +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.
> +++ c
> @@ -165,11 +165,13 @@ HandleCollectionResource (
>    CollectionCs = Collection->MemoryCollection;
> 
> 
> 
>    if (*CollectionCs->Membersodata_count == 0) {
> 
> -    return EFI_NOT_FOUND;
> 
> +    Status = EFI_NOT_FOUND;
> 
> +    goto ON_RELEASE;
> 
>    }
> 
> 
> 
>    if (IsLinkEmpty (&CollectionCs->Members)) {
> 
> -    return EFI_NOT_FOUND;
> 
> +    Status = EFI_NOT_FOUND;
> 
> +    goto ON_RELEASE;
> 
>    }
> 
> 
> 
>    List = GetFirstLink (&CollectionCs->Members);
> 
> @@ -197,12 +199,15 @@ HandleCollectionResource (
>      List = GetNextLink (&CollectionCs->Members, List);
> 
>    }
> 
> 
> 
> +  Status = EFI_SUCCESS;
> 
> +
> 
> +ON_RELEASE:
> 
>    //
> 
>    // Release resource.
> 
>    //
> 
>    Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtocol,
> (EFI_REST_JSON_STRUCTURE_HEADER *)Collection);
> 
> 
> 
> -  return EFI_SUCCESS;
> 
> +  return Status;
> 
>  }
> 
> 
> 
>  EFI_STATUS
> 
> --
> 2.32.0 (Apple Git-132)
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#116565): https://edk2.groups.io/g/devel/message/116565
> Mute This Topic: https://groups.io/mt/104841892/7129762
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [nick...@nvidia.com] -=-=-
> =-=-=-=
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116624): https://edk2.groups.io/g/devel/message/116624
Mute This Topic: https://groups.io/mt/104841892/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to