In order to extend trace_seq into being dynamic, the struct trace_seq
will no longer be valid if simply set to zero. Call trace_seq_init() for
all trace_seq when they are first created.

Suggested-by: Steven Rostedt <rost...@goodmis.org>
Signed-off-by: Ricardo B. Marliere <rica...@marliere.net>
---
 kernel/trace/trace.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 46dbe22121e9..9eddf8168df2 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4889,6 +4889,9 @@ __tracing_open(struct inode *inode, struct file *file, 
bool snapshot)
 
        mutex_unlock(&trace_types_lock);
 
+       trace_seq_init(&iter->seq);
+       trace_seq_init(&iter->tmp_seq);
+
        return iter;
 
  fail:
@@ -6770,6 +6773,7 @@ static int tracing_open_pipe(struct inode *inode, struct 
file *filp)
        }
 
        trace_seq_init(&iter->seq);
+       trace_seq_init(&iter->tmp_seq);
        iter->trace = tr->current_trace;
 
        if (!alloc_cpumask_var(&iter->started, GFP_KERNEL)) {
@@ -6947,6 +6951,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
        trace_iterator_reset(iter);
        cpumask_clear(iter->started);
        trace_seq_init(&iter->seq);
+       trace_seq_init(&iter->tmp_seq);
 
        trace_event_read_lock();
        trace_access_lock(iter->cpu_file);
@@ -8277,6 +8282,9 @@ static int tracing_buffers_open(struct inode *inode, 
struct file *filp)
        if (ret < 0)
                trace_array_put(tr);
 
+       trace_seq_init(&info->iter.seq);
+       trace_seq_init(&info->iter.tmp_seq);
+
        return ret;
 }
 
@@ -10300,6 +10308,9 @@ void trace_init_global_iter(struct trace_iterator *iter)
        iter->temp_size = STATIC_TEMP_BUF_SIZE;
        iter->fmt = static_fmt_buf;
        iter->fmt_size = STATIC_FMT_BUF_SIZE;
+
+       trace_seq_init(&iter->seq);
+       trace_seq_init(&iter->tmp_seq);
 }
 
 void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
@@ -10712,6 +10723,9 @@ void __init early_trace_init(void)
                        tracepoint_printk = 0;
                else
                        static_key_enable(&tracepoint_printk_key.key);
+
+               trace_seq_init(&tracepoint_print_iter->seq);
+               trace_seq_init(&tracepoint_print_iter->tmp_seq);
        }
        tracer_alloc_buffers();
 
-- 
2.43.0


Reply via email to