public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Mike Maslenkin" <mike.maslenkin@gmail.com>
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 2/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions
Date: Sun, 10 Mar 2024 03:41:59 -0700	[thread overview]
Message-ID: <20240310104151.41355-3-mike.maslenkin@gmail.com> (raw)
In-Reply-To: <20240310104151.41355-1-mike.maslenkin@gmail.com>

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>
---
 RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c    | 5 ++++-
 .../Features/BootOption/v1_0_4/Common/BootOptionCommon.c     | 5 ++++-
 .../Features/Memory/V1_7_1/Common/MemoryCommon.c             | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
index 1eb269a84222..f40fe215afeb 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
@@ -247,7 +247,6 @@ ProvisioningBiosProperties (
                                  );
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a, ToJson() failed: %r\n", __func__, Status));
-    return Status;
   }
 
   //
@@ -258,6 +257,10 @@ ProvisioningBiosProperties (
                         (EFI_REST_JSON_STRUCTURE_HEADER *)Bios
                         );
 
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
   return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND);
 }
 
diff --git a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c
index 339c8ba04103..358b32253973 100644
--- a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c
+++ b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c
@@ -334,7 +334,6 @@ ON_RELEASE:
                                  );
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status));
-    return Status;
   }
 
   //
@@ -345,6 +344,10 @@ ON_RELEASE:
                         (EFI_REST_JSON_STRUCTURE_HEADER *)BootOption
                         );
 
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
   return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND);
 }
 
diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
index e873f05ca040..39ec7ec0c34b 100644
--- a/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
+++ b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
@@ -2133,7 +2133,6 @@ ProvisioningMemoryProperties (
                                  );
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a, ToJson() failed: %r\n", __func__, Status));
-    return Status;
   }
 
   //
@@ -2144,6 +2143,10 @@ ProvisioningMemoryProperties (
                         (EFI_REST_JSON_STRUCTURE_HEADER *)Memory
                         );
 
+  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 (#116566): https://edk2.groups.io/g/devel/message/116566
Mute This Topic: https://groups.io/mt/104841893/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2024-03-10 10:42 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 3/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 ` Mike Maslenkin [this message]
2024-03-11 13:18   ` [edk2-devel] [PATCH 2/4][edk2-redfish-client] " Nickle Wang via groups.io
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=20240310104151.41355-3-mike.maslenkin@gmail.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