tracing: Fix memory leak of instance function hash filters
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 11 Dec 2018 04:58:01 +0000 (23:58 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Dec 2018 13:13:06 +0000 (14:13 +0100)
commita28d5f3d9c08a160801754804490dbac4ef9e2e1
tree461a06dc709d2619352a55fec0100bbe1ad822e7
parentb2e08ad9d4cb0d2c6776ff0a73903084ddc7588b
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) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/ftrace.c