Skip to contentSkip to conversation

tracing: Fix uninitialized variable in tracing_set_tracer()

PATCH In review Dheeraj Reddy Jonnalagadda 2 participants 2 messages Jan 7, 2025 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Fix uninitialized variable in tracing_set_tracer()

Fix an issue in the tracing_set_tracer() where the variable ret could be used uninitialized under certain conditions. Specifically, when t->use_max_tr is true but tr->cond_snapshot is false, the code would check the value of ret without first initializing it.

---
 kernel/trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
index a04348ab7ccc..28f111c5b3a5 100644
@@ -6079,7 +6079,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
 #ifdef CONFIG_TRACER_MAX_TRACE
 	bool had_max_tr;
 #endif
-	int ret;
+	int ret = 0;
 
 	guard(mutex)(&trace_types_lock);
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 17 lines · On Tue, 7 Jan 2025 18:29:20 +0530 Dheeraj Reddy Jonnalagadda…

Fix an issue in the tracing_set_tracer() where the variable ret could be used uninitialized under certain conditions. Specifically, when t->use_max_tr is true but tr->cond_snapshot is false, the code would check the value of ret without first initializing it.

---
 kernel/trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +0 -0
index a04348ab7ccc..28f111c5b3a5 100644

kernel/trace/trace.c int tracing_set_tracer(struct trace_array *tr, const char *buf) · line 6085

Quoted 8 lines
kernel/trace/trace.c +1 -1
@@ -6079,7 +6079,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
 #ifdef CONFIG_TRACER_MAX_TRACE
 	bool had_max_tr;
 #endif
-	int ret;
+	int ret = 0;
 
 	guard(mutex)(&trace_types_lock);
 

Incorrect fix. The actual fix is pending:

https://lore.kernel.org/all/[email protected]/

-- Steve