ftrace: Don't allocate ftrace module map if ftrace is disabled
authorYe Bin <yebin10@huawei.com>
Thu, 29 May 2025 11:19:55 +0000 (19:19 +0800)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Mon, 2 Jun 2025 17:12:26 +0000 (13:12 -0400)
If ftrace is disabled, it is meaningless to allocate a module map.
Add a check in allocate_ftrace_mod_map() to not allocate if ftrace is
disabled.

Link: https://lore.kernel.org/20250529111955.2349189-3-yebin@huaweicloud.com
Signed-off-by: Ye Bin <yebin10@huawei.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/ftrace.c

index 84fd2f8..a729168 100644 (file)
@@ -7631,6 +7631,9 @@ allocate_ftrace_mod_map(struct module *mod,
 {
        struct ftrace_mod_map *mod_map;
 
+       if (ftrace_disabled)
+               return NULL;
+
        mod_map = kmalloc(sizeof(*mod_map), GFP_KERNEL);
        if (!mod_map)
                return NULL;