public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of C-structures
@ 2024-03-10 10:41 Mike Maslenkin
  2024-03-10 10:41 ` [edk2-devel] [PATCH 1/4][edk2-redfish-client] RedfishClientPkg: fix memory leak Mike Maslenkin
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Mike Maslenkin @ 2024-03-10 10:41 UTC (permalink / raw)
  To: devel; +Cc: Abner Chang, Igor Kulchytskyy, Nickle Wang, Mike Maslenkin

This set contains fixes for proper deallocation of the structures
returned by JsonStructProtocol->ToStructure().

PR: https://github.com/tianocore/edk2-redfish-client/pull/82

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>




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



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [edk2-devel] [PATCH 1/4][edk2-redfish-client] RedfishClientPkg: fix memory leak
  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 ` 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
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Mike Maslenkin @ 2024-03-10 10:41 UTC (permalink / raw)
  To: devel; +Cc: Mike Maslenkin, Abner Chang, Igor Kulchytskyy, Nickle Wang

This patch fixes leak of EFI_REDFISH_COMPUTERSYSTEMCOLLECTION instance
on error path.

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>
---
 .../ComputerSystemCollectionDxe.c                    | 12 +++++++++---
 .../MemoryCollectionDxe/MemoryCollectionDxe.c        | 11 ++++++++---
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c
index 55a6d07dbf2e..3deefa824629 100644
--- a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c
+++ b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [edk2-devel] [PATCH 2/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions
  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-10 10:41 ` [edk2-devel] [PATCH 3/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions Mike Maslenkin
@ 2024-03-10 10:41 ` Mike Maslenkin
  2024-03-11 13:18   ` Nickle Wang via groups.io
  2024-03-10 10:42 ` [edk2-devel] [PATCH 4/4][edk2-redfish-client] RedfishClientPkg: fix memory leak Mike Maslenkin
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Mike Maslenkin @ 2024-03-10 10:41 UTC (permalink / raw)
  To: devel; +Cc: Mike Maslenkin, Abner Chang, Igor Kulchytskyy, Nickle Wang

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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [edk2-devel] [PATCH 3/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions
  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-10 10:41 ` 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] " Mike Maslenkin
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Mike Maslenkin @ 2024-03-10 10:41 UTC (permalink / raw)
  To: devel; +Cc: Mike Maslenkin, Abner Chang, Igor Kulchytskyy, Nickle Wang

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/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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [edk2-devel] [PATCH 4/4][edk2-redfish-client] RedfishClientPkg: fix memory leak
  2024-03-10 10:41 [edk2-devel] [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of C-structures Mike Maslenkin
                   ` (2 preceding siblings ...)
  2024-03-10 10:41 ` [edk2-devel] [PATCH 2/4][edk2-redfish-client] " Mike Maslenkin
@ 2024-03-10 10:42 ` 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
  5 siblings, 1 reply; 12+ messages in thread
From: Mike Maslenkin @ 2024-03-10 10:42 UTC (permalink / raw)
  To: devel; +Cc: Mike Maslenkin, Abner Chang, Igor Kulchytskyy, Nickle Wang

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_5_0/RedfishResourceIdentifyLibComputerSystem.c    | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/RedfishClientPkg/Library/RedfishResourceIdentifyLibComputerSystem/v1_5_0/RedfishResourceIdentifyLibComputerSystem.c b/RedfishClientPkg/Library/RedfishResourceIdentifyLibComputerSystem/v1_5_0/RedfishResourceIdentifyLibComputerSystem.c
index 29b4f525d5ff..2f177b8032cc 100644
--- a/RedfishClientPkg/Library/RedfishResourceIdentifyLibComputerSystem/v1_5_0/RedfishResourceIdentifyLibComputerSystem.c
+++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibComputerSystem/v1_5_0/RedfishResourceIdentifyLibComputerSystem.c
@@ -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));
@@ -92,6 +93,8 @@ RedfishIdentifyResource (
     Status = EFI_UNSUPPORTED;
   }
 
+ON_RELEASE:
+
   mJsonStructProtocol->DestoryStructure (
                          mJsonStructProtocol,
                          (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem
-- 
2.32.0 (Apple Git-132)



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



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH 1/4][edk2-redfish-client] RedfishClientPkg: fix memory leak
  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
  0 siblings, 0 replies; 12+ messages in thread
From: Nickle Wang via groups.io @ 2024-03-11 13:18 UTC (permalink / raw)
  To: devel@edk2.groups.io, mike.maslenkin@gmail.com
  Cc: Abner Chang, Igor Kulchytskyy



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 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.chang@amd.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Signed-off-by: Mike Maslenkin <mike.maslenkin@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+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 (#116624): https://edk2.groups.io/g/devel/message/116624
Mute This Topic: https://groups.io/mt/104841892/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH 2/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions
  2024-03-10 10:41 ` [edk2-devel] [PATCH 2/4][edk2-redfish-client] " Mike Maslenkin
@ 2024-03-11 13:18   ` Nickle Wang via groups.io
  0 siblings, 0 replies; 12+ messages in thread
From: Nickle Wang via groups.io @ 2024-03-11 13:18 UTC (permalink / raw)
  To: devel@edk2.groups.io, mike.maslenkin@gmail.com
  Cc: Abner Chang, Igor Kulchytskyy



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 2/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>
> ---
>  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/BootOptionCommo
> +++ n.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/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 (#116625): https://edk2.groups.io/g/devel/message/116625
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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH 3/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions
  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
  0 siblings, 0 replies; 12+ messages in thread
From: Nickle Wang via groups.io @ 2024-03-11 13:18 UTC (permalink / raw)
  To: devel@edk2.groups.io, mike.maslenkin@gmail.com
  Cc: Abner Chang, Igor Kulchytskyy



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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH 4/4][edk2-redfish-client] RedfishClientPkg: fix memory leak
  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
  0 siblings, 0 replies; 12+ messages in thread
From: Nickle Wang via groups.io @ 2024-03-11 13:19 UTC (permalink / raw)
  To: devel@edk2.groups.io, mike.maslenkin@gmail.com
  Cc: Abner Chang, Igor Kulchytskyy



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 4/4][edk2-redfish-client] RedfishClientPkg: fix
> memory leak
> 
> 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_5_0/RedfishResourceIdentifyLibComputerSystem.c    | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git
> a/RedfishClientPkg/Library/RedfishResourceIdentifyLibComputerSystem/v1_5_0/
> RedfishResourceIdentifyLibComputerSystem.c
> b/RedfishClientPkg/Library/RedfishResourceIdentifyLibComputerSystem/v1_5_0/
> RedfishResourceIdentifyLibComputerSystem.c
> index 29b4f525d5ff..2f177b8032cc 100644
> ---
> a/RedfishClientPkg/Library/RedfishResourceIdentifyLibComputerSystem/v1_5_0/
> RedfishResourceIdentifyLibComputerSystem.c
> +++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibComputerSystem/
> +++ v1_5_0/RedfishResourceIdentifyLibComputerSystem.c
> @@ -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));
> 
> @@ -92,6 +93,8 @@ RedfishIdentifyResource (
>      Status = EFI_UNSUPPORTED;
> 
>    }
> 
> 
> 
> +ON_RELEASE:
> 
> +
> 
>    mJsonStructProtocol->DestoryStructure (
> 
>                           mJsonStructProtocol,
> 
>                           (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem
> 
> --
> 2.32.0 (Apple Git-132)
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#116568): https://edk2.groups.io/g/devel/message/116568
> Mute This Topic: https://groups.io/mt/104841896/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 (#116627): https://edk2.groups.io/g/devel/message/116627
Mute This Topic: https://groups.io/mt/104841896/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of C-structures
  2024-03-10 10:41 [edk2-devel] [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of C-structures Mike Maslenkin
                   ` (3 preceding siblings ...)
  2024-03-10 10:42 ` [edk2-devel] [PATCH 4/4][edk2-redfish-client] RedfishClientPkg: fix memory leak Mike Maslenkin
@ 2024-03-13  1:03 ` Chang, Abner via groups.io
  2024-03-13 18:41 ` Mike Maslenkin
  5 siblings, 0 replies; 12+ messages in thread
From: Chang, Abner via groups.io @ 2024-03-13  1:03 UTC (permalink / raw)
  To: Mike Maslenkin, devel@edk2.groups.io; +Cc: Igor Kulchytskyy, Nickle Wang

[AMD Official Use Only - General]

For the patch set, Reviewed-by: Abner Chang <abner.chang@amd.com>

Please update each patch with reviewed-by and update the PR.
Thanks Mike.
Abner

> -----Original Message-----
> From: Mike Maslenkin <mike.maslenkin@gmail.com>
> Sent: Sunday, March 10, 2024 6:42 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>; Nickle Wang <nicklew@nvidia.com>; Mike Maslenkin
> <mike.maslenkin@gmail.com>
> Subject: [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of
> C-structures
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> This set contains fixes for proper deallocation of the structures
> returned by JsonStructProtocol->ToStructure().
>
> PR: https://github.com/tianocore/edk2-redfish-client/pull/82
>
> 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>
>



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



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of C-structures
  2024-03-10 10:41 [edk2-devel] [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of C-structures Mike Maslenkin
                   ` (4 preceding siblings ...)
  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
  5 siblings, 1 reply; 12+ messages in thread
From: Mike Maslenkin @ 2024-03-13 18:41 UTC (permalink / raw)
  To: devel; +Cc: Abner Chang, Igor Kulchytskyy, Nickle Wang

On Sun, Mar 10, 2024 at 1:41 PM Mike Maslenkin <mike.maslenkin@gmail.com> wrote:
>
> This set contains fixes for proper deallocation of the structures
> returned by JsonStructProtocol->ToStructure().
>
> PR: https://github.com/tianocore/edk2-redfish-client/pull/82
>
> 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>

I have updated patches with R-b and pushed it to PR.

Thank you for review!

Regards,
Mike


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



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix deallocation of C-structures
  2024-03-13 18:41 ` Mike Maslenkin
@ 2024-03-14  1:10   ` Chang, Abner via groups.io
  0 siblings, 0 replies; 12+ messages in thread
From: Chang, Abner via groups.io @ 2024-03-14  1:10 UTC (permalink / raw)
  To: Mike Maslenkin, devel@edk2.groups.io; +Cc: Igor Kulchytskyy, Nickle Wang

[AMD Official Use Only - General]

Done. Thanks!

> -----Original Message-----
> From: Mike Maslenkin <mike.maslenkin@gmail.com>
> Sent: Thursday, March 14, 2024 2:41 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>; Nickle Wang <nicklew@nvidia.com>
> Subject: Re: [PATCH 0/4][edk2-redfish-client] RedfishClientPkg: fix
> deallocation of C-structures
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Sun, Mar 10, 2024 at 1:41 PM Mike Maslenkin
> <mike.maslenkin@gmail.com> wrote:
> >
> > This set contains fixes for proper deallocation of the structures
> > returned by JsonStructProtocol->ToStructure().
> >
> > PR: https://github.com/tianocore/edk2-redfish-client/pull/82
> >
> > 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>
>
> I have updated patches with R-b and pushed it to PR.
>
> Thank you for review!
>
> Regards,
> Mike


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



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-03-14  1:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [edk2-devel] [PATCH 2/4][edk2-redfish-client] " Mike Maslenkin
2024-03-11 13:18   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox