[PATCH OLK-5.10] trace/fgraph: Fix error handling

From: Guenter Roeck <linux@roeck-us.net> mainline inclusion from mainline-v6.17-rc4 commit ab1396af7595e7d49a3850481b24d7fe7cbdfd31 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICYBCS Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- Commit edede7a6dcd7 ("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: edede7a6dcd7 ("trace/fgraph: Fix the warning caused by missing unregister notifier") Closes: https://lore.kernel.org/all/63b0ba5a-a928-438e-84f9-93028dd72e54@roeck-us.ne... Cc: Ye Weihua <yeweihua4@huawei.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/20250906050618.2634078-1-linux@roeck-us.net Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Conflicts: kernel/trace/fgraph.c [Context conflict, need to integrate the two err handling codes together] Signed-off-by: Tengda Wu <wutengda2@huawei.com> --- kernel/trace/fgraph.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index fd8f06c5dcc3..c920a7556764 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -609,11 +609,8 @@ int register_ftrace_graph(struct fgraph_ops *gops) ftrace_graph_active++; ret = start_graph_tracing(); - if (ret) { - ftrace_graph_active--; - unregister_pm_notifier(&ftrace_suspend_notifier); - goto out; - } + if (ret) + goto out_err; ftrace_graph_return = gops->retfunc; @@ -628,8 +625,12 @@ int register_ftrace_graph(struct fgraph_ops *gops) update_function_graph_func(); ret = ftrace_startup(&graph_ops, FTRACE_START_FUNC_RET); - if (ret) - unregister_pm_notifier(&ftrace_suspend_notifier); +out_err: + if (ret) { + ftrace_graph_active--; + if (!ftrace_graph_active) + unregister_pm_notifier(&ftrace_suspend_notifier); + } out: mutex_unlock(&ftrace_lock); return ret; -- 2.34.1

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/18025 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/E4P... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/18025 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/E4P...
participants (2)
-
patchwork bot
-
Tengda Wu