[PATCH] opal: fix the resource leak for cpus

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


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

Fix resource leak found by coverity,
CID 323867: (#1 of 1): Resource leak (RESOURCE_LEAK)
25. leaked_storage: Variable cpus going out of scope
leaks the storage it points to.

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

diff --git a/src/opal/cpu_info.c b/src/opal/cpu_info.c
index c96a419a..10c3c4ed 100644
--- a/src/opal/cpu_info.c
+++ b/src/opal/cpu_info.c
@@ -203,9 +203,9 @@ static int get_linux_xscom_devices(fwts_framework *fw)
 				failures++;
 			}
 			fwts_log_nl(fw);
-			free(cpus);
 			free(namelist[i]);
 		}
+		free(cpus);
 	}
 	free(namelist);
 
-- 
2.34.1




More information about the fwts-devel mailing list