[PATCH] opal: fix the resource leak for get_linux_mem_devices

Ivan Hu ivan.hu at canonical.com
Tue Feb 27 06:47:30 UTC 2024


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

resource leak found by coverity,
CID 323932: (#1 of 1): Resource leak (RESOURCE_LEAK)
28. leaked_storage: Variable mem_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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c
index 0e173364..0e7e14d4 100644
--- a/src/opal/mem_info.c
+++ b/src/opal/mem_info.c
@@ -399,9 +399,9 @@ static int get_linux_mem_devices(fwts_framework *fw)
 				failures++;
 			}
 			free(mba_path);
-			free(mem_buffer);
 			free(namelist[i]);
 		}
+		free(mem_buffer);
 	}
 	free(namelist);
 
-- 
2.34.1




More information about the fwts-devel mailing list