Skip to content

Commit c45c585

Browse files
committed
ftrace: Free ftrace hashes after they are replaced in the subops code
The subops processing creates new hashes when adding and removing subops. There were some places that the old hashes that were replaced were not freed and this caused some memory leaks. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/20250417135939.245b128d@gandalf.local.home Fixes: 0ae6b8c ("ftrace: Fix accounting of subop hashes") Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 08275e5 commit c45c585

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

kernel/trace/ftrace.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3609,6 +3609,9 @@ static int rebuild_hashes(struct ftrace_hash **filter_hash, struct ftrace_hash *
36093609
}
36103610
}
36113611

3612+
free_ftrace_hash(temp_hash.filter_hash);
3613+
free_ftrace_hash(temp_hash.notrace_hash);
3614+
36123615
temp_hash.filter_hash = *filter_hash;
36133616
temp_hash.notrace_hash = *notrace_hash;
36143617
}
@@ -3703,8 +3706,11 @@ static int ftrace_hash_move_and_update_subops(struct ftrace_ops *subops,
37033706
}
37043707

37053708
ret = rebuild_hashes(&filter_hash, &notrace_hash, ops);
3706-
if (!ret)
3709+
if (!ret) {
37073710
ret = ftrace_update_ops(ops, filter_hash, notrace_hash);
3711+
free_ftrace_hash(filter_hash);
3712+
free_ftrace_hash(notrace_hash);
3713+
}
37083714

37093715
if (ret) {
37103716
/* Put back the original hash */

0 commit comments

Comments
 (0)