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, OOM, and unchecked caller errors in hpp_list__parse()
Date: Mon, 03 Aug 2026 01:28:08 +0000 [thread overview]
Message-ID: <20260803012808.51F7C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803011140.179943-2-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] The newly added error handling `if (ret) goto out;` is bypassed because the `PARSE_LIST` macro silently masks non-terminal errors (like OOM) from individual tokens, undermining the commit's intended fix.
Pre-existing issues:
- [Low] Missing explicit POSIX standard header inclusions for libc functions.
--
--- Patch [1]: [PATCH 1/2] perf c2c: Fix error masking, OOM, and unchecked caller errors in hpp_list__parse() ---
commit 840153db94480f61d734e3e7494d6e8309bb2f8f
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf c2c: Fix error masking, OOM, and unchecked caller errors in hpp_list__parse()
This commit addresses error handling bugs in hpp_list__parse() where output
parsing errors were silently overwritten and OOM conditions for strdup() were
ignored. It also fixes unhandled return values from c2c_hists__reinit() and
hists__iterate_cb() in the calling functions.
> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index c9584dbedf77a..df07e97155df2 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;
> int ret;
>
> + /* strdup() returns NULL on OOM, don't silently treat as empty */
> + if ((output_ && !output) || (sort_ && !sort)) {
> + ret = -ENOMEM;
> + goto out;
> + }
[Severity: Low]
This is a pre-existing issue, but does this file correctly include the POSIX
standard headers for the libc functions it uses? Functions like strdup() and
free() require <string.h> and <stdlib.h>. Relying on implicit inclusion
can cause build failures on musl libc systems.
> PARSE_LIST(output, c2c_hists__init_output);
> + if (ret)
> + goto out;
[Severity: Medium]
Will this properly catch all errors from the parsing callback? Looking at
the PARSE_LIST macro definition:
ret = _fn(hpp_list, tok, env);
if (ret == -EINVAL) {
pr_err("Invalid --fields key: '%s'", tok);
break;
} else if (ret == -ESRCH) {
pr_err("Unknown --fields key: '%s'", tok);
break;
}
If the callback returns an error like -1 due to an allocation failure on a
token that isn't the last in the list, the loop won't break. Does this mean
subsequent iterations could succeed and overwrite ret to 0, causing the newly
added if (ret) goto out; check to be bypassed?
> PARSE_LIST(sort, c2c_hists__init_sort);
> + if (ret)
> + goto out;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803011140.179943-1-acme@kernel.org?part=1
next prev parent reply other threads:[~2026-08-03 1:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 1:11 [PATCHES v2 0/2] perf c2c hardening Arnaldo Carvalho de Melo
2026-08-03 1:11 ` [PATCH 1/2] perf c2c: Fix error masking, OOM, and unchecked caller errors in hpp_list__parse() Arnaldo Carvalho de Melo
2026-08-03 1:28 ` sashiko-bot [this message]
2026-08-03 1:11 ` [PATCH 2/2] perf c2c: Clean up registered formats on c2c_hists__init() failure Arnaldo Carvalho de Melo
-- strict thread matches above, loose matches on Subject: below --
2026-08-03 12:04 [PATCHES v3 0/2] perf c2c hardening Arnaldo Carvalho de Melo
2026-08-03 12:04 ` [PATCH 1/2] perf c2c: Fix error masking, OOM, and unchecked caller errors in hpp_list__parse() Arnaldo Carvalho de Melo
2026-08-03 12:17 ` sashiko-bot
2026-08-03 14:41 [PATCHES v4 0/2] perf c2c hardening Arnaldo Carvalho de Melo
2026-08-03 14:41 ` [PATCH 1/2] perf c2c: Fix error masking, OOM, and unchecked caller errors in hpp_list__parse() Arnaldo Carvalho de Melo
2026-08-03 15:02 ` sashiko-bot
2026-08-03 17:14 ` Arnaldo Carvalho de Melo
2026-08-03 18:01 [PATCHES v5 0/2] perf c2c hardening Arnaldo Carvalho de Melo
2026-08-03 18:01 ` [PATCH 1/2] perf c2c: Fix error masking, OOM, and unchecked caller errors in hpp_list__parse() Arnaldo Carvalho de Melo
2026-08-03 18:07 [PATCHES v6 0/2] perf c2c hardening Arnaldo Carvalho de Melo
2026-08-03 18:07 ` [PATCH 1/2] perf c2c: Fix error masking, OOM, and unchecked caller errors in hpp_list__parse() Arnaldo Carvalho de Melo
2026-08-03 18:26 ` 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=20260803012808.51F7C1F000E9@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