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: 0ae6b8ce200d ("ftrace: Fix accounting of subop hashes")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+7 -1
+7 -1
kernel/trace/ftrace.c
··· 3609 } 3610 } 3611 3612 temp_hash.filter_hash = *filter_hash; 3613 temp_hash.notrace_hash = *notrace_hash; 3614 } ··· 3706 } 3707 3708 ret = rebuild_hashes(&filter_hash, &notrace_hash, ops); 3709 - if (!ret) 3710 ret = ftrace_update_ops(ops, filter_hash, notrace_hash); 3711 3712 if (ret) { 3713 /* Put back the original hash */
··· 3609 } 3610 } 3611 3612 + free_ftrace_hash(temp_hash.filter_hash); 3613 + free_ftrace_hash(temp_hash.notrace_hash); 3614 + 3615 temp_hash.filter_hash = *filter_hash; 3616 temp_hash.notrace_hash = *notrace_hash; 3617 } ··· 3703 } 3704 3705 ret = rebuild_hashes(&filter_hash, &notrace_hash, ops); 3706 + if (!ret) { 3707 ret = ftrace_update_ops(ops, filter_hash, notrace_hash); 3708 + free_ftrace_hash(filter_hash); 3709 + free_ftrace_hash(notrace_hash); 3710 + } 3711 3712 if (ret) { 3713 /* Put back the original hash */