History

tracing: Return error if register_ftrace_function_probe() fails for event_enable_func()

register_ftrace_function_probe() returns the number of functions it registered, which can be zero, it can also return a negative number if something went wrong. But event_enable_func() only checks for the case that it didn't register anything, it needs to also check for the case that something went wrong and return that error code as well. Added some comments about the code as well, to make it more understandable.

Steven Rostedt (Red Hat) committed 13 years ago

Commit ff305de1 parent a5b85bd1 file · +9 −2Browse files

Showing the changes to kernel/trace (1 of 1 file). Show all

Unified · Split

kernel/trace/trace_events.c+9−2
@@ -2061,11 +2061,18 @@ event_enable_func(struct ftrace_hash *hash, · 2060 unmodified lines
20612061 if (ret < 0)
20622062 goto out_put;
20632063 ret = register_ftrace_function_probe(glob, ops, data);
2064+ /*
2065+ * The above returns on success the # of functions enabled,
2066+ * but if it didn't find any functions it returns zero.
2067+ * Consider no functions a failure too.
2068+ */
20642069 if (!ret) {
20652070 ret = -ENOENT;
20662071 goto out_disable;
2067− } else
2068− ret = 0;
2072+ } else if (ret < 0)
2073+ goto out_disable;
2074+ /* Just return zero, not the number of enabled functions */
2075+ ret = 0;
20692076 out:
20702077 mutex_unlock(&event_mutex);
20712078 return ret;