Skip to content

Commit 6348a3f

Browse files
committed
fgraph: Use guard(mutex)(&ftrace_lock) for unregister_ftrace_graph()
The ftrace_lock is held throughout unregister_ftrace_graph(), use a guard to simplify the error paths. Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 4340984 commit 6348a3f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

kernel/trace/fgraph.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,17 +1381,17 @@ void unregister_ftrace_graph(struct fgraph_ops *gops)
13811381
{
13821382
int command = 0;
13831383

1384-
mutex_lock(&ftrace_lock);
1384+
guard(mutex)(&ftrace_lock);
13851385

13861386
if (unlikely(!ftrace_graph_active))
1387-
goto out;
1387+
return;
13881388

13891389
if (unlikely(gops->idx < 0 || gops->idx >= FGRAPH_ARRAY_SIZE ||
13901390
fgraph_array[gops->idx] != gops))
1391-
goto out;
1391+
return;
13921392

13931393
if (fgraph_lru_release_index(gops->idx) < 0)
1394-
goto out;
1394+
return;
13951395

13961396
fgraph_array[gops->idx] = &fgraph_stub;
13971397

@@ -1413,7 +1413,5 @@ void unregister_ftrace_graph(struct fgraph_ops *gops)
14131413
unregister_pm_notifier(&ftrace_suspend_notifier);
14141414
unregister_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
14151415
}
1416-
out:
14171416
gops->saved_func = NULL;
1418-
mutex_unlock(&ftrace_lock);
14191417
}

0 commit comments

Comments
 (0)