[PATCH] objtool: Fix memory leakage

Konstantin Meskhidze posted 1 patch 2 years, 9 months ago
tools/objtool/elf.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] objtool: Fix memory leakage
Posted by Konstantin Meskhidze 2 years, 9 months ago
This commit fixes potential memory leakage in
elf_create_section_symbol() function.

Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
---
 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