lkml.org 
[lkml]   [2017]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[tip:core/urgent] tools/objtool: Fix memory leak in elf_create_rela_section()
Commit-ID:  5b1972d74446bed79df5ddc9674bc3f2a0b6c444
Gitweb: http://git.kernel.org/tip/5b1972d74446bed79df5ddc9674bc3f2a0b6c444
Author: Martin Kepplinger <martink@posteo.de>
AuthorDate: Thu, 14 Sep 2017 08:01:38 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 15 Sep 2017 10:30:30 +0200

tools/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@posteo.de>
Reviewed-by: Don Zickus <dzickus@redhat.com>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: mingo.kernel.org@gmail.com
Link: http://lkml.kernel.org/r/20170914060138.26472-1-martink@posteo.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
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;

\
 
 \ /
  Last update: 2017-09-15 10:47    [W:0.088 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site