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@cmss.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