aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2017-04-19 12:07:08 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-04-19 14:19:08 -0400
commitdf62db5be2e5f070ecd1a5ece5945b590ee112e0 (patch)
treee8a9ded926402162b0e0cd6cd2136f05f28862dd
parent9ed19c7695670d00455c1de4682d5c7f14618689 (diff)
tracing: Allocate the snapshot buffer before enabling probe
Currently the snapshot trigger enables the probe and then allocates the snapshot. If the probe triggers before the allocation, it could cause the snapshot to fail and turn tracing off. It's best to allocate the snapshot buffer first, and then enable the trigger. If something goes wrong in the enabling of the trigger, the snapshot buffer is still allocated, but it can also be freed by the user by writting zero into the snapshot buffer file. Also add a check of the return status of alloc_snapshot(). Cc: stable@vger.kernel.org Fixes: 77fd5c15e3 ("tracing: Add snapshot trigger to function probes") Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--kernel/trace/trace.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d484452ae648..0ad75e9698f6 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6733,11 +6733,13 @@ ftrace_trace_snapshot_callback(struct ftrace_hash *hash,
6733 return ret; 6733 return ret;
6734 6734
6735 out_reg: 6735 out_reg:
6736 ret = register_ftrace_function_probe(glob, ops, count); 6736 ret = alloc_snapshot(&global_trace);
6737 if (ret < 0)
6738 goto out;
6737 6739
6738 if (ret >= 0) 6740 ret = register_ftrace_function_probe(glob, ops, count);
6739 alloc_snapshot(&global_trace);
6740 6741
6742 out:
6741 return ret < 0 ? ret : 0; 6743 return ret < 0 ? ret : 0;
6742} 6744}
6743 6745