[PATCH] objtool: Fix memory leak in check.c
From: Kuan-Wei Chiu
Date: Tue Oct 03 2023 - 12:13:44 EST
In the 'disas_funcs' function of check.c, the 'cmd' string used to store
a command is not being freed after it's used, leading to a memory leak.
This patch adds the necessary 'free(cmd)' statement to release the
allocated memory.
Signed-off-by: Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
---
tools/objtool/check.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index e308d1ba664e..b010b883c1ee 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4589,6 +4589,7 @@ static int disas_funcs(const char *funcs)
/* real snprintf() */
snprintf(cmd, size, objdump_str, cross_compile, objname, funcs);
ret = system(cmd);
+ free(cmd);
if (ret) {
WARN("disassembly failed: %d", ret);
return -1;
--
2.25.1