Skip to content

Commit 1dfb1c7

Browse files
rostedtgregkh
authored andcommitted
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: 77fd5c1 ("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>
1 parent c9460fb commit 1dfb1c7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

kernel/trace/trace.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6060,11 +6060,13 @@ ftrace_trace_snapshot_callback(struct ftrace_hash *hash,
60606060
return ret;
60616061

60626062
out_reg:
6063-
ret = register_ftrace_function_probe(glob, ops, count);
6063+
ret = alloc_snapshot(&global_trace);
6064+
if (ret < 0)
6065+
goto out;
60646066

6065-
if (ret >= 0)
6066-
alloc_snapshot(&global_trace);
6067+
ret = register_ftrace_function_probe(glob, ops, count);
60676068

6069+
out:
60686070
return ret < 0 ? ret : 0;
60696071
}
60706072

0 commit comments

Comments
 (0)