diff mbox

[1/6] tracing: Fix initialization failure path in tracing_set_tracer()

Message ID 1339780111-12075-1-git-send-email-anton.vorontsov@linaro.org
State Superseded
Headers show

Commit Message

Anton Vorontsov June 15, 2012, 5:08 p.m. UTC
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>
---
 kernel/trace/trace.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Steven Rostedt June 15, 2012, 10 p.m. UTC | #1
On Fri, 2012-06-15 at 10:08 -0700, Anton Vorontsov wrote:
> 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>

-- Steve

> ---
>  kernel/trace/trace.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index a7fa070..7647d33 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -3172,10 +3172,10 @@ static int tracing_set_tracer(const char *buf)
>  	}
>  	destroy_trace_option_files(topts);
>  
> -	current_trace = t;
> +	current_trace = &nop_trace;
>  
> -	topts = create_trace_option_files(current_trace);
> -	if (current_trace->use_max_tr) {
> +	topts = create_trace_option_files(t);
> +	if (t->use_max_tr) {
>  		int cpu;
>  		/* we need to make per cpu buffer sizes equivalent */
>  		for_each_tracing_cpu(cpu) {
> @@ -3195,6 +3195,7 @@ static int tracing_set_tracer(const char *buf)
>  			goto out;
>  	}
>  
> +	current_trace = t;
>  	trace_branch_enable(tr);
>   out:
>  	mutex_unlock(&trace_types_lock);
diff mbox

Patch

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a7fa070..7647d33 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3172,10 +3172,10 @@  static int tracing_set_tracer(const char *buf)
 	}
 	destroy_trace_option_files(topts);
 
-	current_trace = t;
+	current_trace = &nop_trace;
 
-	topts = create_trace_option_files(current_trace);
-	if (current_trace->use_max_tr) {
+	topts = create_trace_option_files(t);
+	if (t->use_max_tr) {
 		int cpu;
 		/* we need to make per cpu buffer sizes equivalent */
 		for_each_tracing_cpu(cpu) {
@@ -3195,6 +3195,7 @@  static int tracing_set_tracer(const char *buf)
 			goto out;
 	}
 
+	current_trace = t;
 	trace_branch_enable(tr);
  out:
 	mutex_unlock(&trace_types_lock);