From: Steven Rostedt <rostedt@goodmis.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] tracing: Return ERR_PTR() from expr_str()
Date: Fri, 15 May 2026 12:24:26 -0400 [thread overview]
Message-ID: <20260515122426.1507354a@gandalf.local.home> (raw)
In-Reply-To: <20260417223002.1-tracing-expr-v3-pengpeng@iscas.ac.cn>
On Fri, 17 Apr 2026 20:24:00 +0800
Pengpeng Hou <pengpeng@iscas.ac.cn> wrote:
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 73ea180cad55..954e0beb7f0a 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -1764,13 +1764,14 @@ static void expr_field_str(struct hist_field *field, char *expr)
> static char *expr_str(struct hist_field *field, unsigned int level)
> {
> char *expr;
> + int ret = -EINVAL;
No need for the ret value, use:
char *expr __free(kfree) = NULL;
instead.
>
> if (level > 1)
> - return NULL;
> + return ERR_PTR(-EINVAL);
>
> expr = kzalloc(MAX_FILTER_STR_VAL, GFP_KERNEL);
> if (!expr)
> - return NULL;
> + return ERR_PTR(-ENOMEM);
>
> if (!field->operands[0]) {
> expr_field_str(field, expr);
> @@ -1782,9 +1783,9 @@ static char *expr_str(struct hist_field *field, unsigned int level)
>
> strcat(expr, "-(");
> subexpr = expr_str(field->operands[0], ++level);
> - if (!subexpr) {
> - kfree(expr);
> - return NULL;
> + if (IS_ERR(subexpr)) {
> + ret = PTR_ERR(subexpr);
> + goto free;
The above could then be:
if (IS_ERR(subexpr))
return subexpr;
> }
> strcat(expr, subexpr);
> strcat(expr, ")");
> @@ -1810,13 +1811,16 @@ static char *expr_str(struct hist_field *field, unsigned int level)
> strcat(expr, "*");
> break;
> default:
> - kfree(expr);
> - return NULL;
This could be just:
return ERR_PTR(-EINVAL);
> + goto free;
> }
>
> expr_field_str(field->operands[1], expr);
>
> return expr;
And the above would be:
return_ptr(expr);
> +
> +free:
> + kfree(expr);
> + return ERR_PTR(ret);
And the above isn't needed.
-- Steve
> }
>
prev parent reply other threads:[~2026-05-15 16:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 6:09 [PATCH] tracing/hist: bound expression string construction Pengpeng Hou
2026-04-08 21:27 ` Steven Rostedt
2026-04-09 2:56 ` [PATCH v2] tracing/hist: bound expression strings with seq_buf Pengpeng Hou
2026-04-14 9:10 ` Steven Rostedt
2026-04-17 3:06 ` Pengpeng Hou
2026-04-17 12:24 ` [PATCH v3 1/2] tracing: Return ERR_PTR() from expr_str() Pengpeng Hou
2026-04-17 12:28 ` [PATCH v3 2/2] tracing: Bound histogram expression strings with seq_buf Pengpeng Hou
2026-05-15 16:16 ` Steven Rostedt
2026-05-15 16:24 ` Steven Rostedt [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=20260515122426.1507354a@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=pengpeng@iscas.ac.cn \
/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