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 <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 930d2b3 commit 6c05353

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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)