All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Namhyung Kim" <namhyung@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf c2c: Fix memory leaks on output fields
Date: Thu, 15 Oct 2026 07:02:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-172377@kernel.org> (raw)
In-Reply-To: <20261015064850.43366-1-namhyung@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf: memory leak of format fields on the error path in print_pareto()
--

commit 5a86eb27e5b5cc05d78fa3b2c7aa2c282a65fdb5
Author: Namhyung Kim <namhyung@kernel.org>

perf c2c: Fix memory leaks on output fields

This commit addresses memory leaks by freeing the perf_hpp_list after use.
It adds cleanup calls for the main c2c hists list during report exit and for
a local list in print_pareto().

> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index 4222ac784fabe..b2b07e6a2a717 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c

[ ... ]

> @@ -2577,6 +2582,8 @@ static void print_pareto(FILE *out, struct perf_env *env)
>  		c2c_he = container_of(he, struct c2c_hist_entry, he);
>  		print_cacheline(c2c_he->hists, he, &hpp_list, out);
>  	}
> +
> +	perf_hpp__reset_output_field(&hpp_list);

[Severity: Medium]
Does this leave a memory leak on the error path earlier in print_pareto()?

If hpp_list__parse() fails halfway through allocating format structures, it
returns a non-zero error code but leaves any successfully parsed elements in
the list.

The error path returns early and bypasses this newly added cleanup:

    ret = hpp_list__parse(&hpp_list, cl_output, /*evlist=*/NULL, env);
    if (WARN_ONCE(ret, "failed to setup sort entries\n"))
            return;

Should perf_hpp__reset_output_field() also be called before returning on
that error path?

>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015064850.43366-1-namhyung@kernel.org?part=1

      reply	other threads:[~2026-10-15  7:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  6:48 [PATCH] perf c2c: Fix memory leaks on output fields Namhyung Kim
2026-10-15  7:02 ` sashiko-bot [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=sashiko-outbox-172377@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.