Skip to content

Commit 92f1d3b

Browse files
image-dragonrostedt
authored andcommitted
ftrace: fix incorrect hash size in register_ftrace_direct()
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>
1 parent c45c585 commit 92f1d3b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/trace/ftrace.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5964,9 +5964,10 @@ int register_ftrace_direct(struct ftrace_ops *ops, unsigned long addr)
59645964

59655965
/* Make a copy hash to place the new and the old entries in */
59665966
size = hash->count + direct_functions->count;
5967-
if (size > 32)
5968-
size = 32;
5969-
new_hash = alloc_ftrace_hash(fls(size));
5967+
size = fls(size);
5968+
if (size > FTRACE_HASH_MAX_BITS)
5969+
size = FTRACE_HASH_MAX_BITS;
5970+
new_hash = alloc_ftrace_hash(size);
59705971
if (!new_hash)
59715972
goto out_unlock;
59725973

0 commit comments

Comments
 (0)