The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] objtool: Fix memory leak in decode_instructions()
Date: Thu, 12 Oct 2017 14:32:14 +0530	[thread overview]
Message-ID: <1507798934-18140-1-git-send-email-kamalesh@linux.vnet.ibm.com> (raw)

free the allocated insn before returning, when an error occurs
before adding insn to file->insn_list.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
---
 tools/objtool/check.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a0c518ecf085..c0e26ad1fa7e 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -267,12 +267,13 @@ static int decode_instructions(struct objtool_file *file)
 						      &insn->immediate,
 						      &insn->stack_op);
 			if (ret)
-				return ret;
+				goto err;
 
 			if (!insn->type || insn->type > INSN_LAST) {
 				WARN_FUNC("invalid instruction type %d",
 					  insn->sec, insn->offset, insn->type);
-				return -1;
+				ret = -1;
+				goto err;
 			}
 
 			hash_add(file->insn_hash, &insn->hash, insn->offset);
@@ -296,6 +297,10 @@ static int decode_instructions(struct objtool_file *file)
 	}
 
 	return 0;
+
+err:
+	free(insn);
+	return ret;
 }
 
 /*
-- 
2.11.0

             reply	other threads:[~2017-10-12  9:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12  9:02 Kamalesh Babulal [this message]
2017-10-12 16:10 ` [PATCH] objtool: Fix memory leak in decode_instructions() Josh Poimboeuf
2017-10-13  4:44   ` Kamalesh Babulal
2017-10-13  5:06     ` Josh Poimboeuf
2017-10-13  5:50       ` Kamalesh Babulal
2017-10-19 14:31         ` Josh Poimboeuf
2017-10-19 14:32           ` Josh Poimboeuf
2017-10-22  9:25             ` Kamalesh Babulal
2017-10-19 14:12   ` Josh Poimboeuf
2017-10-19 15:21     ` Ingo Molnar
2017-10-19 15:34       ` Josh Poimboeuf
2017-10-20  7:24         ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2017-10-19 16:27 Josh Poimboeuf

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=1507798934-18140-1-git-send-email-kamalesh@linux.vnet.ibm.com \
    --to=kamalesh@linux.vnet.ibm.com \
    --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