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>
Wed, 19 Dec 2018 18:19:52 +0000 (19:19 +0100)
commitee310e8ebb9eb53ff3294f36f72554e7c1d7ae54
treed14b82ee8efa54c13ad5942f3552b99c902c2176
parent8f01f990b19fdd143f2fe0b6fdc285b148a14f4f
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