Skip to content

Commit ab1396a

Browse files
groeckrostedt
authored andcommitted
trace/fgraph: Fix error handling
Commit edede7a ("trace/fgraph: Fix the warning caused by missing unregister notifier") added a call to unregister the PM notifier if register_ftrace_graph() failed. It does so unconditionally. However, the PM notifier is only registered with the first call to register_ftrace_graph(). If the first registration was successful and a subsequent registration failed, the notifier is now unregistered even if ftrace graphs are still registered. Fix the problem by only unregistering the PM notifier during error handling if there are no active fgraph registrations. Fixes: edede7a ("trace/fgraph: Fix the warning caused by missing unregister notifier") Closes: https://lore.kernel.org/all/[email protected]/ Cc: Ye Weihua <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 80d03a4 commit ab1396a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/trace/fgraph.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,8 @@ int register_ftrace_graph(struct fgraph_ops *gops)
13971397
ftrace_graph_active--;
13981398
gops->saved_func = NULL;
13991399
fgraph_lru_release_index(i);
1400-
unregister_pm_notifier(&ftrace_suspend_notifier);
1400+
if (!ftrace_graph_active)
1401+
unregister_pm_notifier(&ftrace_suspend_notifier);
14011402
}
14021403
return ret;
14031404
}

0 commit comments

Comments
 (0)