public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nickle Wang via groups.io" <nicklew=nvidia.com@groups.io>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"mike.maslenkin@gmail.com" <mike.maslenkin@gmail.com>
Cc: Abner Chang <abner.chang@amd.com>, Igor Kulchytskyy <igork@ami.com>
Subject: Re: [edk2-devel] [PATCH 3/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions
Date: Mon, 11 Mar 2024 06:18:54 -0700	[thread overview]
Message-ID: <MW4PR12MB70316C9489BA9BAB6CFC1CC8D9242@MW4PR12MB7031.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20240310104151.41355-4-mike.maslenkin@gmail.com>



Reviewed-by: Nickle Wang <nicklew@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.maslenkin@gmail.com>; Abner Chang
> <abner.chang@amd.com>; Igor Kulchytskyy <igork@ami.com>; Nickle Wang
> <nicklew@nvidia.com>
> Subject: [edk2-devel] [PATCH 3/4][edk2-redfish-client] RedfishClientPkg: fix leak
> in provisioning properties functions
> 
> External email: Use caution opening links or attachments
> 
> 
> 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>
> ---
>  .../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/ComputerSyst
> emCommon.c
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst
> emCommon.c
> index df22a1c90c46..4795e4d6c6eb 100644
> ---
> a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst
> emCommon.c
> +++
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSy
> +++ stemCommon.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/ComputerSyste
> mCommon.c
> b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSyste
> mCommon.c
> index c383cad59029..2d257e01da2b 100644
> ---
> a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSyste
> mCommon.c
> +++
> b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSys
> +++ temCommon.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/7129762
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [nicklew@nvidia.com] -=-=-
> =-=-=-=
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116626): https://edk2.groups.io/g/devel/message/116626
Mute This Topic: https://groups.io/mt/104841894/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2024-03-11 13:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-10 10:41 [edk2-devel] [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of C-structures Mike Maslenkin
2024-03-10 10:41 ` [edk2-devel] [PATCH 1/4][edk2-redfish-client] RedfishClientPkg: fix memory leak Mike Maslenkin
2024-03-11 13:18   ` Nickle Wang via groups.io
2024-03-10 10:41 ` [edk2-devel] [PATCH 2/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions Mike Maslenkin
2024-03-11 13:18   ` Nickle Wang via groups.io
2024-03-10 10:41 ` [edk2-devel] [PATCH 3/4][edk2-redfish-client] " Mike Maslenkin
2024-03-11 13:18   ` Nickle Wang via groups.io [this message]
2024-03-10 10:42 ` [edk2-devel] [PATCH 4/4][edk2-redfish-client] RedfishClientPkg: fix memory leak Mike Maslenkin
2024-03-11 13:19   ` Nickle Wang via groups.io
2024-03-13  1:03 ` [edk2-devel] [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of C-structures Chang, Abner via groups.io
2024-03-13 18:41 ` Mike Maslenkin
2024-03-14  1:10   ` Chang, Abner via groups.io

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MW4PR12MB70316C9489BA9BAB6CFC1CC8D9242@MW4PR12MB7031.namprd12.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox