From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/2] perf c2c: Fix error masking and OOM handling in hpp_list__parse()
Date: Sun, 02 Aug 2026 14:57:32 +0000 [thread overview]
Message-ID: <20260802145732.ABCCF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260802142313.154514-2-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The patch introduces early exits in `hpp_list__parse` on parsing errors, skipping the critical `perf_hpp__setup_output_field` initialization. Callers like `c2c_hists__reinit` ignore this error, causing histograms to be rendered without necessary output fields.
- [Low] Missing explicit inclusion of `<string.h>` and `<stdlib.h>` for POSIX libc functions introduced by the patch.
--
--- Patch [1]: [PATCH 1/2] perf c2c: Fix error masking and OOM handling in hpp_list__parse() ---
commit 52205c976b0de26bcbb5609f521d63f4dbe4ebec
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf c2c: Fix error masking and OOM handling in hpp_list__parse()
This commit fixes error masking in hpp_list__parse() by checking strdup()
return values and preserving the first error across PARSE_LIST calls.
It prevents silently treating OOM failures as empty input.
> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index c9584dbedf77a..332d360ca5334 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c
[ ... ]
> @@ -2093,8 +2093,18 @@ static int hpp_list__parse(struct perf_hpp_list *hpp_list,
> char *sort = sort_ ? strdup(sort_) : NULL;
[Severity: Low]
Does this file need explicit inclusions for string.h and stdlib.h?
The perf subsystem guidelines require standard POSIX inclusions for musl
compatibility when using functions like strdup() and free().
> int ret;
>
> + /* strdup() returns NULL on OOM, don't silently treat as empty */
> + if ((output_ && !output) || (sort_ && !sort)) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> PARSE_LIST(output, c2c_hists__init_output);
> + if (ret)
> + goto out;
> PARSE_LIST(sort, c2c_hists__init_sort);
> + if (ret)
> + goto out;
>
> /* copy sort keys to output fields */
> perf_hpp__setup_output_field(hpp_list);
[Severity: Medium]
Does skipping perf_hpp__setup_output_field() leave the output fields list
uninitialized when an error occurs?
Callers of hpp_list__parse(), such as resort_cl_cb() and perf_c2c__report(),
appear to ignore its return value. For example:
tools/perf/builtin-c2c.c:resort_cl_cb() {
...
c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort, env);
...
}
tools/perf/builtin-c2c.c:perf_c2c__report() {
...
c2c_hists__reinit(&c2c.hists, output_str, sort_str,
perf_session__env(session));
...
}
If an error is returned due to invalid keys or OOM, the callers proceed with
a broken state, which could lead to rendered histograms without necessary
output fields.
[ ... ]
> @@ -2111,6 +2121,7 @@ static int hpp_list__parse(struct perf_hpp_list *hpp_list,
> perf_hpp__append_sort_keys(&hists->list);
> #endif
>
> +out:
> free(output);
> free(sort);
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260802142313.154514-1-acme@kernel.org?part=1
next prev parent reply other threads:[~2026-08-02 14:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 14:23 [PATCHES 0/2] perf c2c hardening Arnaldo Carvalho de Melo
2026-08-02 14:23 ` [PATCH 1/2] perf c2c: Fix error masking and OOM handling in hpp_list__parse() Arnaldo Carvalho de Melo
2026-08-02 14:57 ` sashiko-bot [this message]
2026-08-02 14:23 ` [PATCH 2/2] perf c2c: Clean up registered formats on c2c_hists__init() failure Arnaldo Carvalho de Melo
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=20260802145732.ABCCF1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acme@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox