[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1467035677-12193-5-git-send-email-pmladek@suse.com>
Date: Mon, 27 Jun 2016 15:54:37 +0200
From: Petr Mladek <pmladek@...e.com>
To: Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>,
Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
Jiri Kosina <jkosina@...e.cz>, linux-kernel@...r.kernel.org,
x86@...nel.org, Petr Mladek <pmladek@...e.com>
Subject: [PATCH 4/4] ftrace: Fixup trace_selftest_ops()
I was hunting a memory leak related to trace_selftest_ops() and found
two small mistakes there.
First, the dynamic trace must be freed in case of error. There was
one wrong goto target. It was even in the original commit
95950c2ecb31314ef ("ftrace: Add self-tests for multiple function
trace users").
Second, ftrace_init_array_ops() is called only when cnt > 1 but
but ftrace_reset_array_ops() is always called. It probably does
not harm but it is strange and might eventually hide a bug.
This was added by the commit 4104d326b670c2 ("ftrace: Remove global
function list and call function directly").
Signed-off-by: Petr Mladek <pmladek@...e.com>
---
kernel/trace/trace_selftest.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index b0f86ea77881..0b5ae79b5b0c 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -272,7 +272,7 @@ static int trace_selftest_ops(struct trace_array *tr, int cnt)
goto out_free;
if (cnt > 1) {
if (trace_selftest_test_global_cnt == 0)
- goto out;
+ goto out_free;
}
if (trace_selftest_test_dyn_cnt == 0)
goto out_free;
@@ -298,9 +298,10 @@ static int trace_selftest_ops(struct trace_array *tr, int cnt)
unregister_ftrace_function(&test_probe1);
unregister_ftrace_function(&test_probe2);
unregister_ftrace_function(&test_probe3);
- if (cnt > 1)
+ if (cnt > 1) {
unregister_ftrace_function(tr->ops);
- ftrace_reset_array_ops(tr);
+ ftrace_reset_array_ops(tr);
+ }
/* Make sure everything is off */
reset_counts();
--
1.8.5.6
Powered by blists - more mailing lists