tracing/trigger: Fix to return error if failed to alloc snapshot

commit 0958b33ef5 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: 0bbe7f7199 ("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>
This commit is contained in:
Masami Hiramatsu (Google) 2024-01-26 09:42:58 +09:00 committed by Greg Kroah-Hartman
parent 76a42074d0
commit 36be97e9eb
1 changed files with 4 additions and 2 deletions

View File

@ -1455,8 +1455,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);
}