linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Vincent Donnefort <vdonnefort@google.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	rostedt@goodmis.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	mathieu.desnoyers@efficios.com, kernel-team@android.com
Subject: [PATCH] tracing/trigger: Fix to return error if failed to alloc snapshot
Date: Fri, 26 Jan 2024 09:42:58 +0900	[thread overview]
Message-ID: <170622977792.270660.2789298642759362200.stgit@devnote2> (raw)
In-Reply-To: <ZbJ19CF2Zv4d0R_Z@google.com>

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Fix register_snapshot_trigger() to return error code if it failed to
allocate a snapshot instead of 0 (success). Unless that, it will register
snapshot trigger without an error.

Fixes: 0bbe7f719985 ("tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 kernel/trace/trace_events_trigger.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index 46439e3bcec4..b33c3861fbbb 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -1470,8 +1470,10 @@ register_snapshot_trigger(char *glob,
 			  struct event_trigger_data *data,
 			  struct trace_event_file *file)
 {
-	if (tracing_alloc_snapshot_instance(file->tr) != 0)
-		return 0;
+	int ret = tracing_alloc_snapshot_instance(file->tr);
+
+	if (ret < 0)
+		return ret;
 
 	return register_trigger(glob, data, file);
 }


  parent reply	other threads:[~2024-01-26  0:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 11:07 [PATCH v12 0/6] Introducing trace buffer mapping by user-space Vincent Donnefort
2024-01-23 11:07 ` [PATCH v12 1/6] ring-buffer: Zero ring-buffer sub-buffers Vincent Donnefort
2024-01-23 11:07 ` [PATCH v12 2/6] ring-buffer: Introducing ring-buffer mapping functions Vincent Donnefort
2024-01-23 15:51   ` Steven Rostedt
2024-01-23 17:48     ` Vincent Donnefort
2024-01-23 18:02       ` Steven Rostedt
2024-01-23 11:07 ` [PATCH v12 3/6] tracing: Add snapshot refcount Vincent Donnefort
2024-01-24 15:11   ` Masami Hiramatsu
2024-01-25 14:53     ` Vincent Donnefort
2024-01-26  0:32       ` Masami Hiramatsu
2024-01-26  0:42       ` Masami Hiramatsu (Google) [this message]
2024-01-26 16:58         ` [PATCH] tracing/trigger: Fix to return error if failed to alloc snapshot Steven Rostedt
2024-01-26  2:01   ` [PATCH v12 3/6] tracing: Add snapshot refcount kernel test robot
2024-01-26  2:21   ` kernel test robot
2024-01-23 11:07 ` [PATCH v12 4/6] tracing: Allow user-space mapping of the ring-buffer Vincent Donnefort
2024-01-23 11:07 ` [PATCH v12 5/6] Documentation: tracing: Add ring-buffer mapping Vincent Donnefort
2024-01-23 11:07 ` [PATCH v12 6/6] ring-buffer/selftest: Add ring-buffer mapping test Vincent Donnefort

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=170622977792.270660.2789298642759362200.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=rostedt@goodmis.org \
    --cc=vdonnefort@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).