[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250922090324.2598-1-liujing@cmss.chinamobile.com>
Date: Mon, 22 Sep 2025 17:03:24 +0800
From: liujing <liujing@...s.chinamobile.com>
To: jpoimboe@...nel.org
Cc: peterz@...radead.org,
linux-kernel@...r.kernel.org,
liujing <liujing@...s.chinamobile.com>
Subject: [PATCH] objtool: fix memory leak in tools/objtool/elf.c
If calloc succeeds but malloc fails (i.e., sym != NULL but name == NULL),
then memory has already been allocated for sym via calloc, but atthis
point sym is not freed, leading to a memory leak.
Signed-off-by: liujing <liujing@...s.chinamobile.com>
---
tools/objtool/elf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index ca5d77db692a..69766f8a49d6 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -859,6 +859,8 @@ elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long size)
if (!sym || !name) {
ERROR_GLIBC("malloc");
+ free(sym);
+ free(name);
return NULL;
}
--
2.27.0
Powered by blists - more mailing lists