Skip to content

Commit e6f4890

Browse files
Lai JiangshanIngo Molnar
authored andcommitted
trace_stat: don't call seq_printf() in seq_operation->start()
Impact: Fix incorrect way using seq_file's API Use SEQ_START_TOKEN instead of calling ->stat_headers() int seq_operation->start(). Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Acked-by: Steven Rostedt <srostedt@redhat.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> LKML-Reference: <49C9EAE5.5070202@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent ee000b7 commit e6f4890

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎kernel/trace/trace_stat.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static void *stat_seq_start(struct seq_file *s, loff_t *pos)
163163

164164
/* If we are in the beginning of the file, print the headers */
165165
if (!*pos && session->ts->stat_headers)
166-
session->ts->stat_headers(s);
166+
return SEQ_START_TOKEN;
167167

168168
return seq_list_start(&session->stat_list, *pos);
169169
}
@@ -172,6 +172,9 @@ static void *stat_seq_next(struct seq_file *s, void *p, loff_t *pos)
172172
{
173173
struct tracer_stat_session *session = s->private;
174174

175+
if (p == SEQ_START_TOKEN)
176+
return seq_list_start(&session->stat_list, *pos);
177+
175178
return seq_list_next(p, &session->stat_list, pos);
176179
}
177180

@@ -186,6 +189,9 @@ static int stat_seq_show(struct seq_file *s, void *v)
186189
struct tracer_stat_session *session = s->private;
187190
struct trace_stat_list *l = list_entry(v, struct trace_stat_list, list);
188191

192+
if (v == SEQ_START_TOKEN)
193+
return session->ts->stat_headers(s);
194+
189195
return session->ts->stat_show(s, l->stat);
190196
}
191197

0 commit comments

Comments
 (0)