]> git.itanic.dy.fi Git - linux-stable/commit
tracing: Allocate the snapshot buffer before enabling probe
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 19 Apr 2017 16:07:08 +0000 (12:07 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Apr 2017 07:12:57 +0000 (09:12 +0200)
commit838a281c4a17486e46cefcb7816e0c2fd1b49648
treebb7da308aeb3d015e0909ed6cdfb7ecd84174f89
parent523ae2e9e39a83b16e016c745922f74a6b3b36d0
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>
kernel/trace/trace.c