Skip to contentSkip to conversation

kernel/trace/trace: check the return value of tracing_update_buffers()

PATCH In review Li Zhong 2 participants 2 messages Sep 17, 2022 – Sep 26, 2022 Tracing

lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 kernel/trace/trace: check the return value of tracing_update_buffers()

Check the return value of tracing_update_buffers() in case it fails.

---
 kernel/trace/trace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace.c +2 -1
index d3005279165d..0e367e326147 100644
@@ -3305,7 +3305,8 @@ void trace_printk_init_buffers(void)
 	pr_warn("**********************************************************\n");
 
 	/* Expand the buffers to set size */
-	tracing_update_buffers();
+	if (tracing_update_buffers() < 0)
+		return;
 
 	buffers_allocated = 1;
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 1 line · On Fri, 16 Sep 2022 19:03:53 -0700 Li Zhong <[email protected]> wrote:

Check the return value of tracing_update_buffers() in case it fails.

FYI, the subject should be:

tracing: Check the return value of tracing_update_buffers()

Quoted 11 lines
---
 kernel/trace/trace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace.c +0 -0
index d3005279165d..0e367e326147 100644

kernel/trace/trace.c void trace_printk_init_buffers(void) · line 3309

Quoted 6 lines
kernel/trace/trace.c +2 -1
@@ -3305,7 +3305,8 @@ void trace_printk_init_buffers(void)
 	pr_warn("**********************************************************\n");
 
 	/* Expand the buffers to set size */
-	tracing_update_buffers();
+	if (tracing_update_buffers() < 0)
+		return;

Even if the buffers are not expanded, tracing can still work. This should not return here. But instead we should have something like:

	/* Allocation really should not fail here at boot up or module load */
	if (tracing_update_buffers() < 0)
		pr_err("Failed to expand tracing buffers for trace_printk() calls\n");
	else
		buffers_allocate = 1;

As we still want the cmdline action done late in the code.

-- Steve

Quoted 3 lines
kernel/trace/trace.c +0 -0
 	buffers_allocated = 1;