Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1731789

[PATCH] tools: objtool: fix memory leak in elf_create_rela_section()

From Martin Kepplinger <martink@posteo.de>
Newsgroups linux.kernel
Subject [PATCH] tools: objtool: fix memory leak in elf_create_rela_section()
Date 2017-09-13 21:00 +0200
Message-ID <upl3d-2DF-27@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Signed-off-by: Martin Kepplinger <martink@posteo.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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] tools: objtool: fix memory leak in elf_create_rela_section() Martin Kepplinger <martink@posteo.de> - 2017-09-13 21:00 +0200

csiph-web