Skip to content

Commit

Permalink
ftrace: fix incorrect hash size in register_ftrace_direct()
Browse files Browse the repository at this point in the history
The maximum of the ftrace hash bits is made fls(32) in
register_ftrace_direct(), which seems illogical. So, we fix it by making
the max hash bits FTRACE_HASH_MAX_BITS instead.

Link: https://lore.kernel.org/20250413014444.36724-1-dongml2@chinatelecom.cn
Fixes: d05cb47 ("ftrace: Fix modification of direct_function hash while in use")
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
  • Loading branch information
Menglong Dong authored and Steven Rostedt (Google) committed Apr 17, 2025
1 parent c45c585 commit 92f1d3b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5964,9 +5964,10 @@ int register_ftrace_direct(struct ftrace_ops *ops, unsigned long addr)

/* Make a copy hash to place the new and the old entries in */
size = hash->count + direct_functions->count;
if (size > 32)
size = 32;
new_hash = alloc_ftrace_hash(fls(size));
size = fls(size);
if (size > FTRACE_HASH_MAX_BITS)
size = FTRACE_HASH_MAX_BITS;
new_hash = alloc_ftrace_hash(size);
if (!new_hash)
goto out_unlock;

Expand Down

0 comments on commit 92f1d3b

Please sign in to comment.