]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
riscv: bpf: Fix uninitialized symbol 'retval_off'
authorChenghao Duan <duanchenghao@kylinos.cn>
Mon, 22 Sep 2025 06:22:44 +0000 (14:22 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:36:52 +0000 (15:36 -0500)
[ Upstream commit d0bf7cd5df18466d969bb60e8890b74cf96081ca ]

In the __arch_prepare_bpf_trampoline() function, retval_off is only
meaningful when save_ret is true, so the current logic is correct.
However, in the original logic, retval_off is only initialized under
certain conditions; for example, in the fmod_ret logic, the compiler is
not aware that the flags of the fmod_ret program (prog) have set
BPF_TRAMP_F_CALL_ORIG, which results in an uninitialized symbol
compilation warning.

So initialize retval_off unconditionally to fix it.

Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>
Reviewed-by: Pu Lehui <pulehui@huawei.com>
Link: https://lore.kernel.org/r/20250922062244.822937-2-duanchenghao@kylinos.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/riscv/net/bpf_jit_comp64.c

index f1efa4d6b27f3ae36bbfe0c084bfc4f3dc44d0a7..bad8c47ed4a7fa36750e1ca65aa591574441a86f 100644 (file)
@@ -1112,10 +1112,9 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
        stack_size += 16;
 
        save_ret = flags & (BPF_TRAMP_F_CALL_ORIG | BPF_TRAMP_F_RET_FENTRY_RET);
-       if (save_ret) {
+       if (save_ret)
                stack_size += 16; /* Save both A5 (BPF R0) and A0 */
-               retval_off = stack_size;
-       }
+       retval_off = stack_size;
 
        stack_size += nr_arg_slots * 8;
        args_off = stack_size;