From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH] tracing: Fix using ret variable in tracing_set_tracer()
Date: Tue, 7 Jan 2025 07:35:58 +0900 [thread overview]
Message-ID: <20250107073558.7dd7753a0973afb2962ae775@kernel.org> (raw)
In-Reply-To: <20250106111143.2f90ff65@gandalf.local.home>
On Mon, 6 Jan 2025 11:11:43 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> When the function tracing_set_tracer() switched over to using the guard()
> infrastructure, it did not need to save the 'ret' variable and would just
> return the value when an error arised, instead of setting ret and jumping
> to an out label.
>
> When CONFIG_TRACER_SNAPSHOT is enabled, it had code that expected the
> "ret" variable to be initialized to zero and had set 'ret' while holding
> an arch_spin_lock() (not used by guard), and then upon releasing the lock
> it would check 'ret' and exit if set. But because ret was only set when an
> error occurred while holding the locks, 'ret' would be used uninitialized
> if there was no error. The code in the CONFIG_TRACER_SNAPSHOT block should
> be self contain. Make sure 'ret' is also set when no error occurred.
>
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thanks,
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202412271654.nJVBuwmF-lkp@intel.com/
> Fixes: d33b10c0c73ad ("tracing: Switch trace.c code over to use guard()")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> kernel/trace/trace.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 0aaf442271e9..5aeb898054e7 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -6104,8 +6104,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
> if (t->use_max_tr) {
> local_irq_disable();
> arch_spin_lock(&tr->max_lock);
> - if (tr->cond_snapshot)
> - ret = -EBUSY;
> + ret = tr->cond_snapshot ? -EBUSY : 0;
> arch_spin_unlock(&tr->max_lock);
> local_irq_enable();
> if (ret)
> --
> 2.45.2
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2025-01-06 22:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 16:11 Steven Rostedt
2025-01-06 22:35 ` Masami Hiramatsu [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=20250107073558.7dd7753a0973afb2962ae775@kernel.org \
--to=mhiramat@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.org \
/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
all inboxes | Powered by JetHome®