Skip to contentSkip to conversation

tracing: Check the return value of tracing_update_buffers()

PATCH In review Steven Rostedt 2 participants 2 messages Jan 7 – Jan 8 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 tracing: Check the return value of tracing_update_buffers()

From: Steven Rostedt <[email protected]>

In the very unlikely event that tracing_update_buffers() fails in trace_printk_init_buffers(), report the failure so that it is known.

---
 kernel/trace/trace.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/trace/trace.c +4 -3
index 2d387d56dcd4..1722e01e2238 100644
@@ -3418,9 +3418,10 @@ void trace_printk_init_buffers(void)
 	pr_warn("**********************************************************\n");
 
 	/* Expand the buffers to set size */
-	tracing_update_buffers(&global_trace);
-
-	buffers_allocated = 1;
+	if (tracing_update_buffers(&global_trace) < 0)
+		pr_err("Failed to expand tracing buffers for trace_printk() calls\n");
+	else
+		buffers_allocated = 1;
 
 	/*
 	 * trace_printk_init_buffers() can be called by modules.
Signature · 1 line
2.51.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Wed, 7 Jan 2026 16:15:10 -0500 Steven Rostedt <[email protected]> wrote:

From: Steven Rostedt <[email protected]>

In the very unlikely event that tracing_update_buffers() fails in trace_printk_init_buffers(), report the failure so that it is known.

Good catch! Looks good to me.

Thanks,

Quoted 29 lines
---
 kernel/trace/trace.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/trace/trace.c +4 -3
index 2d387d56dcd4..1722e01e2238 100644
@@ -3418,9 +3418,10 @@ void trace_printk_init_buffers(void)
 	pr_warn("**********************************************************\n");
 
 	/* Expand the buffers to set size */
-	tracing_update_buffers(&global_trace);
-
-	buffers_allocated = 1;
+	if (tracing_update_buffers(&global_trace) < 0)
+		pr_err("Failed to expand tracing buffers for trace_printk() calls\n");
+	else
+		buffers_allocated = 1;
 
 	/*
 	 * trace_printk_init_buffers() can be called by modules.
Signature · 1 line
2.51.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>