]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpf: arm64: Fix sparse warnings
authorPuranjay Mohan <puranjay@kernel.org>
Fri, 19 Dec 2025 19:13:08 +0000 (11:13 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 22 Dec 2025 00:57:23 +0000 (16:57 -0800)
ctx->image is declared as __le32 because arm64 instructions are LE
regardless of CPU's runtime endianness. emit_u32_data() emits raw data
and not instructions so cast the value to __le32 to fix the sparse
warning.

Cast function pointer to void * before doing arithmetic.

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Link: https://lore.kernel.org/r/20251219191310.3204425-1-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/arm64/net/bpf_jit_comp.c

index b6eb7a465ad248164db927bc8f0f2d01124e77da..0c4d44bcfbf498fe74176a0758ca451f748f30f5 100644 (file)
@@ -118,7 +118,7 @@ static inline void emit(const u32 insn, struct jit_ctx *ctx)
 static inline void emit_u32_data(const u32 data, struct jit_ctx *ctx)
 {
        if (ctx->image != NULL && ctx->write)
-               ctx->image[ctx->idx] = data;
+               ctx->image[ctx->idx] = (__force __le32)data;
 
        ctx->idx++;
 }
@@ -3139,7 +3139,7 @@ void bpf_jit_free(struct bpf_prog *prog)
                        bpf_jit_binary_pack_finalize(jit_data->ro_header, jit_data->header);
                        kfree(jit_data);
                }
-               prog->bpf_func -= cfi_get_offset();
+               prog->bpf_func = (void *)prog->bpf_func - cfi_get_offset();
                hdr = bpf_jit_binary_pack_hdr(prog);
                bpf_jit_binary_pack_free(hdr, NULL);
                priv_stack_ptr = prog->aux->priv_stack_ptr;