From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 3/4] perf metricgroup: Fix realloc() leaks in resolve_metric() and __add_metric()
Date: Wed, 18 Nov 2026 07:58:39 +0000 [thread overview]
Message-ID: <sashiko-outbox-220393@kernel.org> (raw)
In-Reply-To: <20261118075516.1278903-4-irogers@google.com>
> In resolve_metric(), growing the pending array assigns the result of
> realloc() directly back to pending; if realloc() fails after earlier
> iterations succeeded, the existing pending allocation is overwritten
> with NULL and leaked.
>
> Similarly, in __add_metric(), assigning realloc() directly to
> root_metric->metric_refs overwrites the existing pointer with NULL on
> failure, preventing metric__free(root_metric) in the root caller from
> freeing the prior metric_refs array.
>
> Use temporary pointers for both realloc() calls, freeing pending before
> returning -ENOMEM in resolve_metric() and preserving
> root_metric->metric_refs for metric__free() in __add_metric().
>
> Fixes: 80be6434c36f ("perf metric: Modify resolution and recursion check")
> Fixes: 46bdc0bf8d21 ("perf metric: Simplify metric_refs calculation")
> Signed-off-by: Ian Rogers <irogers@google.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118075516.1278903-1-irogers@google.com?part=3
next prev parent reply other threads:[~2026-11-18 7:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 7:55 [PATCH v1 0/4] perf tools: Fix thread cache race, stat per-pkg delta bug, and memory leaks Ian Rogers
2026-11-18 7:55 ` [PATCH v1 1/4] perf threads: Don't resurrect removed threads in last_match Ian Rogers
2026-11-18 8:03 ` sashiko-bot
2026-11-18 7:55 ` [PATCH v1 2/4] perf stat: Don't corrupt zero or prev_raw_counts on skipped per-pkg CPUs Ian Rogers
2026-11-18 7:55 ` [PATCH v1 3/4] perf metricgroup: Fix realloc() leaks in resolve_metric() and __add_metric() Ian Rogers
2026-11-18 7:58 ` sashiko-bot [this message]
2026-11-18 7:55 ` [PATCH v1 4/4] perf pmu: Free alias on error paths in perf_pmu__new_alias() Ian Rogers
2026-11-18 7:59 ` sashiko-bot
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-220393@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.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.