[edk2-devel] [PATCH v3 05/16] RedfishPkg: RedfishDiscoverDxe: fix memory leak on error path.

Mike Maslenkin posted 16 patches 2 years, 1 month ago
[edk2-devel] [PATCH v3 05/16] RedfishPkg: RedfishDiscoverDxe: fix memory leak on error path.
Posted by Mike Maslenkin 2 years, 1 month ago
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
---
 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 06d8d00da7fb..e344e06d8dcc 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -829,6 +829,10 @@ AddAndSignalNewRedfishService (
     } while (TRUE);
   }
 
+  if (Char16Uuid != NULL) {
+    FreePool (Char16Uuid);
+  }
+
   if (NewFound || InfoRefresh) {
     if (!InfoRefresh) {
       DiscoveredList = (EFI_REDFISH_DISCOVERED_INTERNAL_LIST *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVERED_INTERNAL_LIST));
@@ -907,10 +911,6 @@ AddAndSignalNewRedfishService (
     }
   }
 
-  if (Char16Uuid != NULL) {
-    FreePool ((VOID *)Char16Uuid);
-  }
-
   Status = EFI_SUCCESS;
   if (NewFound || InfoRefresh) {
     //
-- 
2.32.0 (Apple Git-132)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112864): https://edk2.groups.io/g/devel/message/112864
Mute This Topic: https://groups.io/mt/103354124/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-