Commit 0b2aee59 authored by Steven Rostedt (VMware)'s avatar Steven Rostedt (VMware) Committed by Thadeu Lima de Souza Cascardo

tracing: Allocate the snapshot buffer before enabling probe

BugLink: http://bugs.launchpad.net/bugs/1687638

commit df62db5b 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: 77fd5c15 ("tracing: Add snapshot trigger to function probes")
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
parent 9f4376a4
......@@ -6060,11 +6060,13 @@ ftrace_trace_snapshot_callback(struct ftrace_hash *hash,
return ret;
out_reg:
ret = register_ftrace_function_probe(glob, ops, count);
ret = alloc_snapshot(&global_trace);
if (ret < 0)
goto out;
if (ret >= 0)
alloc_snapshot(&global_trace);
ret = register_ftrace_function_probe(glob, ops, count);
out:
return ret < 0 ? ret : 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment