Skip to contentSkip to conversation

objtool: Fix memory leak in check.c

PATCH In review Kuan-Wei Chiu 2 participants 2 messages Oct 3, 2023 objtool

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 objtool: Fix memory leak in check.c

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.

---
 tools/objtool/check.c | 1 +
 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
index e308d1ba664e..b010b883c1ee 100644
@@ -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;
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 4 lines · 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.

It'll exit more or less right after doing this.