linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Yicong Yang <yangyicong@huawei.com>
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	 mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
	jolsa@kernel.org,  irogers@google.com, adrian.hunter@intel.com,
	linux-perf-users@vger.kernel.org,  linux-kernel@vger.kernel.org,
	jonathan.cameron@huawei.com,  hejunhao3@huawei.com,
	yangyicong@hisilicon.com, linuxarm@huawei.com
Subject: Re: [PATCH 1/2] perf header: Fix one memory leakage in perf_event__fprintf_event_update()
Date: Tue, 12 Dec 2023 17:17:49 -0800	[thread overview]
Message-ID: <CAM9d7cgW9YaS7+2Y0zPszbkSZpu2XgJjW3GP+yig4C-++vJ4-g@mail.gmail.com> (raw)
In-Reply-To: <20231207081635.8427-2-yangyicong@huawei.com>

Hello,

On Thu, Dec 7, 2023 at 12:20 AM Yicong Yang <yangyicong@huawei.com> wrote:
>
> From: Yicong Yang <yangyicong@hisilicon.com>
>
> When dump the raw trace by `perf report -D` ASan reports a memory
> leakage in perf_event__fprintf_event_update(). It shows that we
> allocated a temporary cpumap for dumping the CPUs but doesn't
> release it and it's not used elsewhere. Fix this by free the
> cpumap after the dumping.
>
> Fixes: c853f9394b7b ("perf tools: Add perf_event__fprintf_event_update function")
> Cc: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/util/header.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index e86b9439ffee..7190f39ccd13 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -4369,9 +4369,10 @@ size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp)
>                 ret += fprintf(fp, "... ");
>
>                 map = cpu_map__new_data(&ev->cpus.cpus);
> -               if (map)
> +               if (map) {
>                         ret += cpu_map__fprintf(map, fp);
> -               else
> +                       perf_cpu_map__put(map);
> +               } else
>                         ret += fprintf(fp, "failed to get cpus\n");
>                 break;
>         default:
> --
> 2.24.0
>
>

  reply	other threads:[~2023-12-13  1:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07  8:16 [PATCH 0/2] Perf fix two memory leakage Yicong Yang
2023-12-07  8:16 ` [PATCH 1/2] perf header: Fix one memory leakage in perf_event__fprintf_event_update() Yicong Yang
2023-12-13  1:17   ` Namhyung Kim [this message]
2023-12-07  8:16 ` [PATCH 2/2] perf hisi-ptt: Fix one memory leakage in hisi_ptt_process_auxtrace_event() Yicong Yang
2023-12-13  1:20   ` Namhyung Kim
2023-12-07 18:45 ` [PATCH 0/2] Perf fix two memory leakage Ian Rogers

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=CAM9d7cgW9YaS7+2Y0zPszbkSZpu2XgJjW3GP+yig4C-++vJ4-g@mail.gmail.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=hejunhao3@huawei.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=yangyicong@hisilicon.com \
    --cc=yangyicong@huawei.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;
as well as URLs for NNTP newsgroup(s).