[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240323065550.603005-1-lumingyindetect@163.com>
Date: Sat, 23 Mar 2024 14:55:50 +0800
From: LuMingYin <lumingyindetect@....com>
To: linux-kernel@...r.kernel.org
Cc: peterz@...radead.org,
LuMingYin <lumingyindetect@....com>
Subject: [PATCH] tools:Fix a memory leak bug related to the cmd
In the function 'disas_funcs' defined in the file /linux/tools/objtool/check.c, a pointer variable named 'cmd' is declared (line 4583 of the file). This pointer variable allocates a block of dynamic memory using the 'malloc' function at line 4615. However, after using the memory area pointed to by 'cmd' (line 4619), it is not deallocated, resulting in a memory leak bug. This commit fixes the bug.
Signed-off-by: LuMingYin <lumingyindetect@....com>
---
tools/objtool/check.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index eb7e12ebc1d0..486a2a6374f5 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4617,6 +4617,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
Powered by blists - more mailing lists