aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2017-04-19 12:07:08 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-04-27 03:10:37 -0400
commitd4decac1edaadefe03bc011785cc622a64e8f19a (patch)
treefdaa36927d902e13e6c8bd333c7284307e4738cf
parent174a74dbca2ddc7269c265598399c000e5b9b870 (diff)
tracing: Allocate the snapshot buffer before enabling probe
commit df62db5be2e5f070ecd1a5ece5945b590ee112e0 upstream. 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(). Fixes: 77fd5c15e3 ("tracing: Add snapshot trigger to function probes") Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.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 862bc8805d97..83c60f9013cb 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6481,11 +6481,13 @@ ftrace_trace_snapshot_callback(struct ftrace_hash *hash,
6481 return ret; 6481 return ret;
6482 6482
6483 out_reg: 6483 out_reg:
6484 ret = register_ftrace_function_probe(glob, ops, count); 6484 ret = alloc_snapshot(&global_trace);
6485 if (ret < 0)
6486 goto out;
6485 6487
6486 if (ret >= 0) 6488 ret = register_ftrace_function_probe(glob, ops, count);
6487 alloc_snapshot(&global_trace);
6488 6489
6490 out:
6489 return ret < 0 ? ret : 0; 6491 return ret < 0 ? ret : 0;
6490} 6492}
6491 6493