Skip to content

Commit 6c05353

Browse files
committed
tracing: Switch trace_stack.c code over to use guard()
The function stack_trace_sysctl() uses a goto on the error path to jump to the mutex_unlock() code. Replace the logic to use guard() and let the compiler worry about it. 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: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/20241225222931.684913592@goodmis.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 930d2b3 commit 6c05353

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

kernel/trace/trace_stack.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,20 +520,18 @@ stack_trace_sysctl(const struct ctl_table *table, int write, void *buffer,
520520
int was_enabled;
521521
int ret;
522522

523-
mutex_lock(&stack_sysctl_mutex);
523+
guard(mutex)(&stack_sysctl_mutex);
524524
was_enabled = !!stack_tracer_enabled;
525525

526526
ret = proc_dointvec(table, write, buffer, lenp, ppos);
527527

528528
if (ret || !write || (was_enabled == !!stack_tracer_enabled))
529-
goto out;
529+
return ret;
530530

531531
if (stack_tracer_enabled)
532532
register_ftrace_function(&trace_ops);
533533
else
534534
unregister_ftrace_function(&trace_ops);
535-
out:
536-
mutex_unlock(&stack_sysctl_mutex);
537535
return ret;
538536
}
539537

0 commit comments

Comments
 (0)