Skip to content

Commit 46ef2be

Browse files
oleg-nesterovSteven Rostedt
authored andcommitted
tracing: Change tracing_buffers_fops to rely on tracing_get_cpu()
tracing_buffers_open() is racy, the memory inode->i_private points to can be already freed. Change debugfs_create_file("trace_pipe_raw", data) caller to pass "data = tr", tracing_buffers_open() can use tracing_get_cpu(). Change debugfs_create_file("snapshot_raw_fops", data) caller too, this file uses tracing_buffers_open/release. Link: http://lkml.kernel.org/r/20130723152600.GA23720@redhat.com Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 1554420 commit 46ef2be

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4949,8 +4949,7 @@ static const struct file_operations snapshot_raw_fops = {
49494949

49504950
static int tracing_buffers_open(struct inode *inode, struct file *filp)
49514951
{
4952-
struct trace_cpu *tc = inode->i_private;
4953-
struct trace_array *tr = tc->tr;
4952+
struct trace_array *tr = inode->i_private;
49544953
struct ftrace_buffer_info *info;
49554954
int ret;
49564955

@@ -4969,7 +4968,7 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp)
49694968
mutex_lock(&trace_types_lock);
49704969

49714970
info->iter.tr = tr;
4972-
info->iter.cpu_file = tc->cpu;
4971+
info->iter.cpu_file = tracing_get_cpu(inode);
49734972
info->iter.trace = tr->current_trace;
49744973
info->iter.trace_buffer = &tr->trace_buffer;
49754974
info->spare = NULL;
@@ -5576,7 +5575,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
55765575
&data->trace_cpu, cpu, &tracing_fops);
55775576

55785577
trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu,
5579-
&data->trace_cpu, cpu, &tracing_buffers_fops);
5578+
tr, cpu, &tracing_buffers_fops);
55805579

55815580
trace_create_cpu_file("stats", 0444, d_cpu,
55825581
&data->trace_cpu, cpu, &tracing_stats_fops);
@@ -5589,7 +5588,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
55895588
&data->trace_cpu, cpu, &snapshot_fops);
55905589

55915590
trace_create_cpu_file("snapshot_raw", 0444, d_cpu,
5592-
&data->trace_cpu, cpu, &snapshot_raw_fops);
5591+
tr, cpu, &snapshot_raw_fops);
55935592
#endif
55945593
}
55955594

0 commit comments

Comments
 (0)