summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>2024-01-26 09:42:58 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-23 08:12:56 +0100
commitbcf4a115a5068f3331fafb8c176c1af0da3d8b19 (patch)
treec188c59d664ad0c6dca93a431685830b7f9c54f8
parent04b9c13dc116af8ad88b98d6a96765e0fa4a2b23 (diff)
downloadlinux-stable-bcf4a115a5068f3331fafb8c176c1af0da3d8b19.tar.gz
linux-stable-bcf4a115a5068f3331fafb8c176c1af0da3d8b19.tar.bz2
linux-stable-bcf4a115a5068f3331fafb8c176c1af0da3d8b19.zip
tracing/trigger: Fix to return error if failed to alloc snapshot
commit 0958b33ef5a04ed91f61cef4760ac412080c4e08 upstream. 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. Link: https://lore.kernel.org/linux-trace-kernel/170622977792.270660.2789298642759362200.stgit@devnote2 Fixes: 0bbe7f719985 ("tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation") Cc: stable@vger.kernel.org Cc: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--kernel/trace/trace_events_trigger.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index 4b0bde304ad7..8cb4ddb88601 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -1133,8 +1133,10 @@ register_snapshot_trigger(char *glob, struct event_trigger_ops *ops,
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, ops, data, file);
}