mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chen Wandun <chenwandun@huawei.com>
To: <jpoimboe@redhat.com>, <peterz@infradead.org>,
	<linux-kernel@vger.kernel.org>
Cc: <chenwandun@huawei.com>
Subject: [PATCH] objtool: fix potential memory leak special_get_alts()
Date: Thu, 2 Jul 2020 19:00:25 +0800	[thread overview]
Message-ID: <20200702110025.16883-1-chenwandun@huawei.com> (raw)

If get_alt_entry() return error, struct special_alt will leak.

Fixes: 442f04c34a1a ("objtool: Add tool to perform compile-time stack metadata validation")
Signed-off-by: Chen Wandun <chenwandun@huawei.com>
---
 tools/objtool/special.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/special.c b/tools/objtool/special.c
index e893f1e48e44..90a6ba2d5895 100644
--- a/tools/objtool/special.c
+++ b/tools/objtool/special.c
@@ -188,8 +188,10 @@ int special_get_alts(struct elf *elf, struct list_head *alts)
 			memset(alt, 0, sizeof(*alt));
 
 			ret = get_alt_entry(elf, entry, sec, idx, alt);
-			if (ret)
+			if (ret) {
+				free(alt);
 				return ret;
+			}
 
 			list_add_tail(&alt->list, alts);
 		}
-- 
2.17.1


             reply	other threads:[~2020-07-02 11:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 11:00 Chen Wandun [this message]
2020-07-02 11:05 ` Peter Zijlstra

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=20200702110025.16883-1-chenwandun@huawei.com \
    --to=chenwandun@huawei.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.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®