]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fgraph: Use guard(mutex)(&ftrace_lock) for unregister_ftrace_graph()
authorSteven Rostedt <rostedt@goodmis.org>
Mon, 28 Oct 2024 07:12:29 +0000 (03:12 -0400)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 29 Oct 2024 11:43:02 +0000 (07:43 -0400)
The ftrace_lock is held throughout unregister_ftrace_graph(), use a guard
to simplify the error paths.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/20241028071307.770550792@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/fgraph.c

index 001abf376c0c2abb81b9835729f9199b0ab1c98a..0bf78517b5d4caad5aa2f342da32577ea792f918 100644 (file)
@@ -1381,17 +1381,17 @@ void unregister_ftrace_graph(struct fgraph_ops *gops)
 {
        int command = 0;
 
-       mutex_lock(&ftrace_lock);
+       guard(mutex)(&ftrace_lock);
 
        if (unlikely(!ftrace_graph_active))
-               goto out;
+               return;
 
        if (unlikely(gops->idx < 0 || gops->idx >= FGRAPH_ARRAY_SIZE ||
                     fgraph_array[gops->idx] != gops))
-               goto out;
+               return;
 
        if (fgraph_lru_release_index(gops->idx) < 0)
-               goto out;
+               return;
 
        fgraph_array[gops->idx] = &fgraph_stub;
 
@@ -1413,7 +1413,5 @@ void unregister_ftrace_graph(struct fgraph_ops *gops)
                unregister_pm_notifier(&ftrace_suspend_notifier);
                unregister_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
        }
- out:
        gops->saved_func = NULL;
-       mutex_unlock(&ftrace_lock);
 }