Skip to content

Commit 27de809

Browse files
Björn Töpelkuba-moo
authored andcommitted
riscv, bpf: Fix potential NULL dereference
The bpf_jit_binary_free() function requires a non-NULL argument. When the RISC-V BPF JIT fails to converge in NR_JIT_ITERATIONS steps, jit_data->header will be NULL, which triggers a NULL dereference. Avoid this by checking the argument, prior calling the function. Fixes: ca6cb54 ("riscv, bpf: Factor common RISC-V JIT code") Signed-off-by: Björn Töpel <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 20af886 commit 27de809

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/riscv/net/bpf_jit_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
125125

126126
if (i == NR_JIT_ITERATIONS) {
127127
pr_err("bpf-jit: image did not converge in <%d passes!\n", i);
128-
bpf_jit_binary_free(jit_data->header);
128+
if (jit_data->header)
129+
bpf_jit_binary_free(jit_data->header);
129130
prog = orig_prog;
130131
goto out_offset;
131132
}

0 commit comments

Comments
 (0)