tracing: Fix initialization failure path in tracing_set_tracer()
If tracer->init() fails, current code will leave current_tracer pointing to an unusable tracer, which at best makes 'current_tracer' report inaccurate value. Fix the issue by pointing current_tracer to nop tracer, and only update current_tracer with the new one after all the initialization succeeds. Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> Acked-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c1743cbc8d
commit
b2ad368beb
1 changed files with 4 additions and 3 deletions
|
@ -3172,10 +3172,10 @@ static int tracing_set_tracer(const char *buf)
|
||||||
}
|
}
|
||||||
destroy_trace_option_files(topts);
|
destroy_trace_option_files(topts);
|
||||||
|
|
||||||
current_trace = t;
|
current_trace = &nop_trace;
|
||||||
|
|
||||||
topts = create_trace_option_files(current_trace);
|
topts = create_trace_option_files(t);
|
||||||
if (current_trace->use_max_tr) {
|
if (t->use_max_tr) {
|
||||||
int cpu;
|
int cpu;
|
||||||
/* we need to make per cpu buffer sizes equivalent */
|
/* we need to make per cpu buffer sizes equivalent */
|
||||||
for_each_tracing_cpu(cpu) {
|
for_each_tracing_cpu(cpu) {
|
||||||
|
@ -3195,6 +3195,7 @@ static int tracing_set_tracer(const char *buf)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_trace = t;
|
||||||
trace_branch_enable(tr);
|
trace_branch_enable(tr);
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&trace_types_lock);
|
mutex_unlock(&trace_types_lock);
|
||||||
|
|
Reference in a new issue