mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: "Kunwu.Chan" <chentao@kylinos.cn>,
	peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
	jolsa@kernel.org, namhyung@kernel.org, irogers@google.com,
	kan.liang@linux.intel.com, seanjc@google.com,
	kprateek.nayak@amd.com, robert.richter@amd.com
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	kunwu.chan@hotmail.com
Subject: Re: [PATCH] perf tools: Put the function return operation at the end of the function
Date: Thu, 12 Oct 2023 08:02:45 +0300	[thread overview]
Message-ID: <54481503-67c6-40ec-a02a-31f4db4205f7@intel.com> (raw)
In-Reply-To: <20231012031003.842368-1-chentao@kylinos.cn>

On 12/10/23 06:10, Kunwu.Chan wrote:
> Function return operations should be performed after resource release.
> 
> Fixes: 4e1b9c679fcb ("perf tools: Refactor print_event_desc()")
> Signed-off-by: Kunwu.Chan <chentao@kylinos.cn>
> ---
>  tools/perf/util/header.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index d812e1e371a7..5763f21844b1 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -1998,13 +1998,14 @@ static struct evsel *read_event_desc(struct feat_fd *ff)
>  			id++;
>  		}
>  	}
> -out:
> -	free(buf);
> -	return events;
> +
>  error:
>  	free_event_desc(events);
>  	events = NULL;

Always freeing the events is wrong.  That path is only for errors.

That would show up if this had been tested.

> -	goto out;
> +
> +out:
> +	free(buf);
> +	return events;
>  }
>  
>  static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,


  reply	other threads:[~2023-10-12  5:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12  3:10 Kunwu.Chan
2023-10-12  5:02 ` Adrian Hunter [this message]
2023-10-12  6:53   ` [PATCH v2] " Kunwu.Chan

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=54481503-67c6-40ec-a02a-31f4db4205f7@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=chentao@kylinos.cn \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=kprateek.nayak@amd.com \
    --cc=kunwu.chan@hotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=robert.richter@amd.com \
    --cc=seanjc@google.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
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®