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 15:02:29 +0000 [thread overview]
Message-ID: <20260803150230.0AB731F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803144119.185637-2-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The `%m` format specifier is used in `__hpp_list__parse` to log generic callback errors, which can result in incorrect or stale error messages.
--
--- Patch [1]: [PATCH 1/2] perf c2c: Fix error masking, OOM, and unchecked caller errors in hpp_list__parse() ---
commit 318c268818f1c0f5bf8bb06a4099029b27a33ee1
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 multiple bugs in hpp_list__parse(). It ensures that errors
from output and sort parsing are not silently masked, handles OOM conditions
from strdup() correctly, and properly propagates failures out of the strtok loop
and up the call chain.
> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index c9584dbedf77a..b0f2ba8318304 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c
[ ... ]
> @@ -2063,26 +2065,34 @@ static int c2c_hists__init_sort(struct perf_hpp_list *hpp_list, char *name, stru
[ ... ]
> +static int __hpp_list__parse(struct perf_hpp_list *hpp_list, char *_list, struct perf_env *env,
> + int (*_fn)(struct perf_hpp_list *hpp_list, char *name, struct perf_env *env))
> +{
> + char *tmp, *tok;
> + int ret = 0;
> +
> + if (!_list)
> + return 0;
> +
> + for (tok = strtok_r(_list, ", ", &tmp); tok; tok = strtok_r(NULL, ", ", &tmp)) {
> + ret = _fn(hpp_list, tok, env);
> + switch (ret) {
> + case 0:
> + continue;
> + case -EINVAL:
> + pr_err("Invalid --fields key: `%s'", tok);
> + goto out;
> + case -ESRCH:
> + pr_err("Unknown --fields key: `%s'", tok);
> + goto out;
> + default:
> + pr_err("%m for --fields key: `%s'", tok);
[Severity: Medium]
Will %m print the correct error message here?
The _fn callback returns a negative error code in ret (such as -ENOMEM), but it
does not necessarily set errno.
Even if it did, if the callback or its callees log anything, functions called
internally by pr_err() (like fprintf or localtime_r) can clobber errno even on
success. This could cause %m to print a stale or incorrect error string (e.g.,
"No such file or directory" instead of "Cannot allocate memory").
Could we format the string using the actual error code available in ret instead
of relying on the implicit global errno variable?
> + goto out;
> + }
> + }
> +out:
> + return ret;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803144119.185637-1-acme@kernel.org?part=1
next prev parent reply other threads:[~2026-08-03 15:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-08-03 17:14 ` Arnaldo Carvalho de Melo
2026-08-03 14:41 ` [PATCH 2/2] perf c2c: Clean up registered formats on c2c_hists__init() failure Arnaldo Carvalho de Melo
2026-08-03 15:07 ` sashiko-bot
-- strict thread matches above, loose matches on Subject: below --
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
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 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 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
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=20260803150230.0AB731F000E9@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