Re: [PATCH] libbpf: avoid possible use of uninitialized mod_len

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2025-07-29 at 09:17 -0700, Yonghong Song wrote:
> 
> On 7/29/25 2:45 AM, Achill Gilgenast wrote:
> > If not fn_name, mod_len does never get initialized which fails now with
> > gcc15 on Alpine Linux edge:
> > 
> > 	libbpf.c: In function 'find_kernel_btf_id.constprop':
> > 	libbpf.c:10100:33: error: 'mod_len' may be used uninitialized [-Werror=maybe-uninitialized]
> > 	10100 |                 if (mod_name && strncmp(mod->name, mod_name, mod_len) != 0)
> > 	      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 	libbpf.c:10070:21: note: 'mod_len' was declared here
> > 	10070 |         int ret, i, mod_len;
> > 	      |                     ^~~~~~~
> > 
> > Fixes: 8f8a024272f3 ("libbpf: support "module: Function" syntax for tracing programs")
> > Signed-off-by: Achill Gilgenast <fossdd@xxxxxxxxxx>
> 
> The code itself is actually okay. The error is triggered due to'maybe-uninitialized'.
> To silence the compilation error, I think this change is okay.
> 
> Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx>

I agree with Yonghong, `mod_len` is only read if mod_name != NULL,
meaning that "if (fn_name) { ... mod_name = ...; mod_len = ... }"
block was executed.

Please drop the "Fixes" tag.

Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx>

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux