Skip to content

Commit 90e94bc

Browse files
ftrace: fix incorrect hash size in register_ftrace_direct()
JIRA: https://issues.redhat.com/browse/RHEL-115358 commit 92f1d3b Author: Menglong Dong <menglong8.dong@gmail.com> Date: Sun Apr 13 09:44:44 2025 +0800 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> Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
1 parent 79d437e commit 90e94bc

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
@@ -5944,9 +5944,10 @@ int register_ftrace_direct(struct ftrace_ops *ops, unsigned long addr)
59445944

59455945
/* Make a copy hash to place the new and the old entries in */
59465946
size = hash->count + direct_functions->count;
5947-
if (size > 32)
5948-
size = 32;
5949-
new_hash = alloc_ftrace_hash(fls(size));
5947+
size = fls(size);
5948+
if (size > FTRACE_HASH_MAX_BITS)
5949+
size = FTRACE_HASH_MAX_BITS;
5950+
new_hash = alloc_ftrace_hash(size);
59505951
if (!new_hash)
59515952
goto out_unlock;
59525953

0 commit comments

Comments
 (0)