[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20170913185238.26162-1-martink@posteo.de>
Date: Wed, 13 Sep 2017 20:52:38 +0200
From: Martin Kepplinger <martink@...teo.de>
To: jpoimboe@...hat.com
Cc: linux-kernel@...r.kernel.org, Martin Kepplinger <martink@...teo.de>
Subject: [PATCH] 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@...teo.de>
---
tools/objtool/elf.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 6e9f980a7d26..6aacbc31316d 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -508,8 +508,12 @@ 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);
- if (!sec)
+ if (!sec) {
+ free(relaname);
return NULL;
+ }
+
+ free(relaname);
base->rela = sec;
sec->base = base;
--
2.11.0
Powered by blists - more mailing lists