[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220524104527.3a07878d@gandalf.local.home>
Date: Tue, 24 May 2022 10:45:27 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Song Liu <song@...nel.org>
Cc: <linux-kernel@...r.kernel.org>, <mingo@...hat.com>,
<kernel-team@...com>, <stable@...r.kernel.org>
Subject: Re: [PATCH] ftrace: clean up hash direct_functions on register
failures
On Thu, 12 May 2022 15:08:08 -0700
Song Liu <song@...nel.org> wrote:
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -4465,7 +4465,7 @@ int ftrace_func_mapper_add_ip(struct ftrace_func_mapper *mapper,
> * @ip: The instruction pointer address to remove the data from
> *
> * Returns the data if it is found, otherwise NULL.
> - * Note, if the data pointer is used as the data itself, (see
> + * Note, if the data pointer is used as the data itself, (see
> * ftrace_func_mapper_find_ip(), then the return value may be meaningless,
> * if the data pointer was set to zero.
> */
> @@ -5200,8 +5200,10 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr)
>
> if (!ret && !(direct_ops.flags & FTRACE_OPS_FL_ENABLED)) {
> ret = register_ftrace_function(&direct_ops);
> - if (ret)
> + if (ret) {
> ftrace_set_filter_ip(&direct_ops, ip, 1, 0);
> + remove_hash_entry(direct_functions, entry);
> + }
> }
>
> if (ret) {
Perhaps something like this is more robust?
-- Steve
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4f1d2f5e7263..cd38ad490174 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5195,8 +5195,6 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr)
goto out_unlock;
ret = ftrace_set_filter_ip(&direct_ops, ip, 0, 0);
- if (ret)
- remove_hash_entry(direct_functions, entry);
if (!ret && !(direct_ops.flags & FTRACE_OPS_FL_ENABLED)) {
ret = register_ftrace_function(&direct_ops);
@@ -5205,6 +5203,7 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr)
}
if (ret) {
+ remove_hash_entry(direct_functions, entry);
kfree(entry);
if (!direct->count) {
list_del_rcu(&direct->next);
Powered by blists - more mailing lists