llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing/probes: Avoid using params uninitialized in parse_btf_arg()
@ 2025-07-16  3:19 Nathan Chancellor
  2025-07-16  4:16 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2025-07-16  3:19 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: Mathieu Desnoyers, linux-kernel, linux-trace-kernel, llvm, stable,
	Nathan Chancellor

After a recent change in clang to strengthen uninitialized warnings [1],
it points out that in one of the error paths in parse_btf_arg(), params
is used uninitialized:

  kernel/trace/trace_probe.c:660:19: warning: variable 'params' is uninitialized when used here [-Wuninitialized]
    660 |                         return PTR_ERR(params);
        |                                        ^~~~~~

Match many other NO_BTF_ENTRY error cases and return -ENOENT, clearing
up the warning.

Cc: stable@vger.kernel.org
Closes: https://github.com/ClangBuiltLinux/linux/issues/2110
Fixes: d157d7694460 ("tracing/probes: Support BTF field access from $retval")
Link: https://github.com/llvm/llvm-project/commit/2464313eef01c5b1edf0eccf57a32cdee01472c7 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 kernel/trace/trace_probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 424751cdf31f..40830a3ecd96 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -657,7 +657,7 @@ static int parse_btf_arg(char *varname,
 		ret = query_btf_context(ctx);
 		if (ret < 0 || ctx->nr_params == 0) {
 			trace_probe_log_err(ctx->offset, NO_BTF_ENTRY);
-			return PTR_ERR(params);
+			return -ENOENT;
 		}
 	}
 	params = ctx->params;

---
base-commit: 6921d1e07cb5eddec830801087b419194fde0803
change-id: 20250715-trace_probe-fix-const-uninit-warning-7dc3accce903

Best regards,
--  
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tracing/probes: Avoid using params uninitialized in parse_btf_arg()
  2025-07-16  3:19 [PATCH] tracing/probes: Avoid using params uninitialized in parse_btf_arg() Nathan Chancellor
@ 2025-07-16  4:16 ` Masami Hiramatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2025-07-16  4:16 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Steven Rostedt, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel, llvm, stable

On Tue, 15 Jul 2025 20:19:44 -0700
Nathan Chancellor <nathan@kernel.org> wrote:

> After a recent change in clang to strengthen uninitialized warnings [1],
> it points out that in one of the error paths in parse_btf_arg(), params
> is used uninitialized:
> 
>   kernel/trace/trace_probe.c:660:19: warning: variable 'params' is uninitialized when used here [-Wuninitialized]
>     660 |                         return PTR_ERR(params);
>         |                                        ^~~~~~
> 
> Match many other NO_BTF_ENTRY error cases and return -ENOENT, clearing
> up the warning.

Good catch! let me pick this up.

Thank you,


> 
> Cc: stable@vger.kernel.org
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2110
> Fixes: d157d7694460 ("tracing/probes: Support BTF field access from $retval")
> Link: https://github.com/llvm/llvm-project/commit/2464313eef01c5b1edf0eccf57a32cdee01472c7 [1]
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  kernel/trace/trace_probe.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index 424751cdf31f..40830a3ecd96 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -657,7 +657,7 @@ static int parse_btf_arg(char *varname,
>  		ret = query_btf_context(ctx);
>  		if (ret < 0 || ctx->nr_params == 0) {
>  			trace_probe_log_err(ctx->offset, NO_BTF_ENTRY);
> -			return PTR_ERR(params);
> +			return -ENOENT;
>  		}
>  	}
>  	params = ctx->params;
> 
> ---
> base-commit: 6921d1e07cb5eddec830801087b419194fde0803
> change-id: 20250715-trace_probe-fix-const-uninit-warning-7dc3accce903
> 
> Best regards,
> --  
> Nathan Chancellor <nathan@kernel.org>
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-16  4:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16  3:19 [PATCH] tracing/probes: Avoid using params uninitialized in parse_btf_arg() Nathan Chancellor
2025-07-16  4:16 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).