linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miroslav Benes <mbenes@suse.cz>
To: gushengxian <gushengxian507419@gmail.com>
Cc: jpoimboe@redhat.com, peterz@infradead.org,
	linux-kernel@vger.kernel.org,
	gushengxian <gushengxian@yulong.com>
Subject: Re: [PATCH] objtool: avoid Memory leak: orig_alt_group
Date: Fri, 2 Jul 2021 10:26:28 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LSU.2.21.2107021021510.29699@pobox.suse.cz> (raw)
In-Reply-To: <20210702031327.559429-1-gushengxian507419@gmail.com>

Hi,

On Thu, 1 Jul 2021, gushengxian wrote:

> From: gushengxian <gushengxian@yulong.com>
> 
> free(orig_alt_group) should be added in order to avoid memery leak.
> Reported by cppcheck.
> 
> Signed-off-by: gushengxian <gushengxian@yulong.com>

It is not necessary. Objtool would exit immediately in case of this error 
and we do not handle the allocations in such cases. 

> ---
>  tools/objtool/check.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index e5947fbb9e7a..deb48b1bc16d 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -1097,6 +1097,7 @@ static int handle_group_alt(struct objtool_file *file,
>  				     sizeof(struct cfi_state *));
>  	if (!orig_alt_group->cfi) {
>  		WARN("calloc failed");
> +		free(orig_alt_group);
>  		return -1;
>  	}

There are more sites like this in the code. For example there is one a 
couple of lines later in the same function. It is fine.

Regards
Miroslav

      reply	other threads:[~2021-07-02  8:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-02  3:13 [PATCH] objtool: avoid Memory leak: orig_alt_group gushengxian
2021-07-02  8:26 ` Miroslav Benes [this message]

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=alpine.LSU.2.21.2107021021510.29699@pobox.suse.cz \
    --to=mbenes@suse.cz \
    --cc=gushengxian507419@gmail.com \
    --cc=gushengxian@yulong.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;
as well as URLs for NNTP newsgroup(s).