[tip:core/urgent] objtool: Fix memory leak in elf_create_rela_section()

From: tip-bot for Martin Kepplinger
Date: Fri Sep 15 2017 - 05:40:31 EST

Commit-ID: 0998b7a0befdf6e734032895ee639a5e6f88cc3f
Gitweb: http://git.kernel.org/tip/0998b7a0befdf6e734032895ee639a5e6f88cc3f
Author: Martin Kepplinger <martink@xxxxxxxxx>
AuthorDate: Thu, 14 Sep 2017 08:01:38 +0200
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitDate: Fri, 15 Sep 2017 11:31:43 +0200

objtool: Fix memory leak in elf_create_rela_section()

Let's free the allocated char array 'relaname' before returning,
in order to avoid leaking memory.

Signed-off-by: Martin Kepplinger <martink@xxxxxxxxx>
Acked-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: mingo.kernel.org@xxxxxxxxx
Link: http://lkml.kernel.org/r/20170914060138.26472-1-martink@xxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
tools/objtool/elf.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 6e9f980..1e89a5f 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -508,6 +508,7 @@ struct section *elf_create_rela_section(struct elf *elf, struct section *base)
strcat(relaname, base->name);

sec = elf_create_section(elf, relaname, sizeof(GElf_Rela), 0);
+ free(relaname);
if (!sec)
return NULL;