[PATCH] objtool: Fix memory leakage

From: Konstantin Meskhidze
Date: Wed Nov 30 2022 - 05:45:56 EST


This commit fixes potential memory leakage in
elf_create_section_symbol() function.

Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@xxxxxxxxxx>
---
tools/objtool/elf.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 7e24b09b1163..58f30840358f 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -776,6 +776,7 @@ elf_create_section_symbol(struct elf *elf, struct section *sec)

if (elf_update_symbol(elf, symtab, symtab_shndx, old)) {
WARN("elf_update_symbol move");
+ free(sym);
return NULL;
}

@@ -785,6 +786,7 @@ elf_create_section_symbol(struct elf *elf, struct section *sec)
sym->idx = new_idx;
if (elf_update_symbol(elf, symtab, symtab_shndx, sym)) {
WARN("elf_update_symbol");
+ free(sym);
return NULL;
}

--
2.25.1