From: Steven Rostedt (VMware) Date: Tue, 11 Dec 2018 04:58:01 +0000 (-0500) Subject: tracing: Fix memory leak of instance function hash filters X-Git-Tag: v3.18.131~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ed458ca7200de54f4e1ccb40b7361c77ba50d75;p=thirdparty%2Fkernel%2Fstable.git tracing: Fix memory leak of instance function hash filters commit 2840f84f74035e5a535959d5f17269c69fa6edc5 upstream. The following commands will cause a memory leak: # cd /sys/kernel/tracing # mkdir instances/foo # echo schedule > instance/foo/set_ftrace_filter # rmdir instances/foo The reason is that the hashes that hold the filters to set_ftrace_filter and set_ftrace_notrace are not freed if they contain any data on the instance and the instance is removed. Found by kmemleak detector. Cc: stable@vger.kernel.org Fixes: 591dffdade9f ("ftrace: Allow for function tracing instance to filter functions") Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index f01d4ecdf5ab5..11d860f16a737 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -4496,6 +4496,7 @@ void ftrace_destroy_filter_files(struct ftrace_ops *ops) if (ops->flags & FTRACE_OPS_FL_ENABLED) ftrace_shutdown(ops, 0); ops->flags |= FTRACE_OPS_FL_DELETED; + ftrace_free_filter(ops); mutex_unlock(&ftrace_lock); }