[PATCH] opal: fix the resource leak for process_dimm and process_mba

Ivan Hu ivan.hu at canonical.com
Mon Mar 18 08:48:12 UTC 2024


BugLink: https://bugs.launchpad.net/fwts/+bug/2058206

fix resource leak found by coverity,
CID 323922: (#1 of 1): Resource leak (RESOURCE_LEAK)
28. leaked_storage: Variable my_buffer going out of scope
leaks the storage it points to.

Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
 src/opal/mem_info.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c
index 0e7e14d4..54f96392 100644
--- a/src/opal/mem_info.c
+++ b/src/opal/mem_info.c
@@ -223,9 +223,9 @@ static int process_dimm(
 				}
 			}
 			free(my_path);
-			free(my_buffer);
 			free(namelist[i]);
 		}
+		free(my_buffer);
 	}
 	free(namelist);
 
@@ -310,9 +310,9 @@ static int process_mba(
 				failures++;
 			}
 			free(my_path);
-			free(my_buffer);
 			free(namelist[i]);
 		}
+		free(my_buffer);
 	}
 	free(namelist);
 
-- 
2.34.1




More information about the fwts-devel mailing list