Skip to content

Commit 9b6c15a

Browse files
committed
fix
1 parent 6367ae6 commit 9b6c15a

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

kernel/trace/ftrace.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5960,17 +5960,6 @@ static void register_ftrace_direct_cb(struct rcu_head *rhp)
59605960
free_ftrace_hash(fhp);
59615961
}
59625962

5963-
static void reset_direct(struct ftrace_ops *ops, unsigned long addr)
5964-
{
5965-
struct ftrace_hash *hash = ops->func_hash->filter_hash;
5966-
5967-
remove_direct_functions_hash(hash, addr);
5968-
5969-
/* cleanup for possible another register call */
5970-
ops->func = NULL;
5971-
ops->trampoline = 0;
5972-
}
5973-
59745963
static struct ftrace_hash *hash_from_ip(unsigned long ip, unsigned long addr)
59755964
{
59765965
struct ftrace_hash *hash;
@@ -6132,6 +6121,18 @@ static struct ftrace_hash *hash_add(struct ftrace_hash *a, struct ftrace_hash *b
61326121
return NULL;
61336122
}
61346123

6124+
static void reset_direct_hash(struct ftrace_ops *ops, struct ftrace_hash **hashp)
6125+
{
6126+
struct ftrace_hash *free_hash = direct_functions;
6127+
6128+
rcu_assign_pointer(direct_functions, *hashp);
6129+
*hashp = free_hash;
6130+
6131+
/* cleanup for possible another register call */
6132+
ops->func = NULL;
6133+
ops->trampoline = 0;
6134+
}
6135+
61356136
int update_ftrace_direct_add(struct ftrace_ops *ops, struct ftrace_hash *hash)
61366137
{
61376138
struct ftrace_hash *filter_hash = NULL, *new_hash = NULL, *free_hash = NULL;
@@ -6189,6 +6190,9 @@ int update_ftrace_direct_add(struct ftrace_ops *ops, struct ftrace_hash *hash)
61896190
err = ftrace_update_ops(ops, filter_hash, EMPTY_HASH);
61906191
}
61916192

6193+
if (err)
6194+
reset_direct_hash(ops, &free_hash);
6195+
61926196
out_unlock:
61936197
mutex_unlock(&direct_mutex);
61946198

@@ -6283,8 +6287,10 @@ int update_ftrace_direct_del(struct ftrace_ops *ops, struct ftrace_hash *hash)
62836287
err = ftrace_update_ops(ops, filter_hash, EMPTY_HASH);
62846288
}
62856289

6286-
free_hash = direct_functions;
6287-
rcu_assign_pointer(direct_functions, new_hash);
6290+
if (!err) {
6291+
free_hash = direct_functions;
6292+
rcu_assign_pointer(direct_functions, new_hash);
6293+
}
62886294

62896295
out_unlock:
62906296
mutex_unlock(&direct_mutex);

0 commit comments

Comments
 (0)