LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Martin Kepplinger <martink@posteo.de>
To: mingo.kernel.org@gmail.com, jpoimboe@redhat.com
Cc: linux-kernel@vger.kernel.org, Martin Kepplinger <martink@posteo.de>
Subject: [PATCH v2] tools: objtool: fix memory leak in elf_create_rela_section()
Date: Thu, 14 Sep 2017 08:01:38 +0200
Message-ID: <20170914060138.26472-1-martink@posteo.de> (raw)
In-Reply-To: <20170914053145.7clhcoauwecrldi2@gmail.com>

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

Signed-off-by: Martin Kepplinger <martink@posteo.de>
---

I should've allocated some brain resources before freeing some computer's.

 tools/objtool/elf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 6e9f980a7d26..1e89a5f8bfc9 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;
 
-- 
2.11.0

  reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-13 22:41 [PATCH] " Josh Poimboeuf
2017-09-14  5:31 ` Ingo Molnar
2017-09-14  6:01   ` Martin Kepplinger [this message]
2017-09-14 12:50     ` [PATCH v2] " Josh Poimboeuf
2017-09-14 14:06     ` [tip:core/urgent] tools/objtool: Fix " tip-bot for Martin Kepplinger
2017-09-15  8:43     ` tip-bot for Martin Kepplinger
2017-09-15  9:36     ` [tip:core/urgent] objtool: " tip-bot for Martin Kepplinger

Reply instructions:

You may reply publically 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=20170914060138.26472-1-martink@posteo.de \
    --to=martink@posteo.de \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo.kernel.org@gmail.com \
    /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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox