mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
tracing: Allocate the snapshot buffer before enabling probe
commitdf62db5be2upstream. 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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
174a74dbca
commit
d4decac1ed
@@ -6481,11 +6481,13 @@ ftrace_trace_snapshot_callback(struct ftrace_hash *hash,
|
||||
return ret;
|
||||
|
||||
out_reg:
|
||||
ret = alloc_snapshot(&global_trace);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
ret = register_ftrace_function_probe(glob, ops, count);
|
||||
|
||||
if (ret >= 0)
|
||||
alloc_snapshot(&global_trace);
|
||||
|
||||
out:
|
||||
return ret < 0 ? ret : 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user