mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Martin Kepplinger <martink@posteo.de>
To: jpoimboe@redhat.com
Cc: linux-kernel@vger.kernel.org, Martin Kepplinger <martink@posteo.de>
Subject: [PATCH] tools: objtool: fix memory leak in elf_create_rela_section()
Date: Wed, 13 Sep 2017 20:52:38 +0200	[thread overview]
Message-ID: <20170913185238.26162-1-martink@posteo.de> (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

             reply	other threads:[~2017-09-13 18:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-13 18:52 Martin Kepplinger [this message]
2017-09-13 22:41 Josh Poimboeuf
2017-09-14  5:31 ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170913185238.26162-1-martink@posteo.de \
    --to=martink@posteo.de \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®