Skip to content

Commit

Permalink
tracing: Reset iterator in t_start()
Browse files Browse the repository at this point in the history
The iterator is m->private, but it's not reset to trace_types in
t_start(). If the output is larger than PAGE_SIZE and t_start()
is called the 2nd time, things will go wrong.

Reviewed-by: Liming Wang <liming.wang@windriver.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4A418728.5020506@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Jun 24, 2009
1 parent 2961bf3 commit f129e96
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2053,25 +2053,23 @@ static int tracing_open(struct inode *inode, struct file *file)
static void *
t_next(struct seq_file *m, void *v, loff_t *pos)
{
struct tracer *t = m->private;
struct tracer *t = v;

(*pos)++;

if (t)
t = t->next;

m->private = t;

return t;
}

static void *t_start(struct seq_file *m, loff_t *pos)
{
struct tracer *t = m->private;
struct tracer *t;
loff_t l = 0;

mutex_lock(&trace_types_lock);
for (; t && l < *pos; t = t_next(m, t, &l))
for (t = trace_types; t && l < *pos; t = t_next(m, t, &l))
;

return t;
Expand Down Expand Up @@ -2107,18 +2105,10 @@ static struct seq_operations show_traces_seq_ops = {

static int show_traces_open(struct inode *inode, struct file *file)
{
int ret;

if (tracing_disabled)
return -ENODEV;

ret = seq_open(file, &show_traces_seq_ops);
if (!ret) {
struct seq_file *m = file->private_data;
m->private = trace_types;
}

return ret;
return seq_open(file, &show_traces_seq_ops);
}

static ssize_t
Expand Down

0 comments on commit f129e96

Please sign in to comment.