From: Masami Hiramatsu Date: Thu, 9 May 2013 05:44:14 +0000 (+0900) Subject: tracing: Don't succeed if event_enable_func did not register anything X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a5b85bd1557209b4ef18a8cf07e60a1ca3132468;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git tracing: Don't succeed if event_enable_func did not register anything Return 0 instead of the number of activated ftrace function probes if event_enable_func succeeded and return an error code if it failed or did not register any functions. But it currently returns the number of registered functions and if it didn't register anything, it returns 0, but that is considered success. This also fixes the return value. As if it succeeds, it returns the number of functions that were enabled, which is returned back to the user in ftrace_regex_write (the write() return code). If only one function is enabled, then the return code of the write is one, and this can confuse the user program in thinking it only wrote 1 byte. Link: http://lkml.kernel.org/r/20130509054413.30398.55650.stgit@mhiramat-M0-7522 Cc: Srikar Dronamraju Cc: Oleg Nesterov Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Tom Zanussi Signed-off-by: Masami Hiramatsu [ Rewrote change log to reflect that this fixes two bugs - SR ] Signed-off-by: Steven Rostedt --- diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 53582e982e51..44ac83614c3d 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2061,8 +2061,11 @@ event_enable_func(struct ftrace_hash *hash, if (ret < 0) goto out_put; ret = register_ftrace_function_probe(glob, ops, data); - if (!ret) + if (!ret) { + ret = -ENOENT; goto out_disable; + } else + ret = 0; out: mutex_unlock(&event_mutex); return ret;