* [PATCH] objtool: Fix memory leak in check.c
@ 2023-10-03 16:13 Kuan-Wei Chiu
2023-10-03 16:26 ` Peter Zijlstra
0 siblings, 1 reply; 2+ messages in thread
From: Kuan-Wei Chiu @ 2023-10-03 16:13 UTC (permalink / raw)
To: jpoimboe, peterz; +Cc: linux-kernel, Kuan-Wei Chiu
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@gmail.com>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] objtool: Fix memory leak in check.c
2023-10-03 16:13 [PATCH] objtool: Fix memory leak in check.c Kuan-Wei Chiu
@ 2023-10-03 16:26 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2023-10-03 16:26 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: jpoimboe, linux-kernel
On Wed, Oct 04, 2023 at 12:13:35AM +0800, Kuan-Wei Chiu wrote:
> 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.
It'll exit more or less right after doing this.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-03 16:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03 16:13 [PATCH] objtool: Fix memory leak in check.c Kuan-Wei Chiu
2023-10-03 16:26 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®