Skip to content

Commit 3b75dd7

Browse files
leitaorostedt
authored andcommitted
tracing: branch: Fix inverted check on stat tracer registration
init_annotated_branch_stats() and all_annotated_branch_stats() check the return value of register_stat_tracer() with "if (!ret)", but register_stat_tracer() returns 0 on success and a negative errno on failure. The inverted check causes the warning to be printed on every successful registration, e.g.: Warning: could not register annotated branches stats while leaving real failures silent. The initcall also returned a hard-coded 1 instead of the actual error. Invert the check and propagate ret so that the warning fires on real errors and the initcall reports the correct status. Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Frederic Weisbecker <fweisbec@gmail.com> Link: https://patch.msgid.link/20260420-tracing-v1-1-d8f4cd0d6af1@debian.org Fixes: 002bb86 ("tracing/ftrace: separate events tracing and stats tracing engine") Signed-off-by: Breno Leitao <leitao@debian.org> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 254f496 commit 3b75dd7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

kernel/trace/trace_branch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,10 @@ __init static int init_annotated_branch_stats(void)
373373
int ret;
374374

375375
ret = register_stat_tracer(&annotated_branch_stats);
376-
if (!ret) {
376+
if (ret) {
377377
printk(KERN_WARNING "Warning: could not register "
378378
"annotated branches stats\n");
379-
return 1;
379+
return ret;
380380
}
381381
return 0;
382382
}
@@ -438,10 +438,10 @@ __init static int all_annotated_branch_stats(void)
438438
int ret;
439439

440440
ret = register_stat_tracer(&all_branch_stats);
441-
if (!ret) {
441+
if (ret) {
442442
printk(KERN_WARNING "Warning: could not register "
443443
"all branches stats\n");
444-
return 1;
444+
return ret;
445445
}
446446
return 0;
447447
}

0 commit comments

Comments
 (0)