[PATCH bpf-next v2 3/7] parisc: Fix memory leak in bpf_jit_free

From: Pu Lehui

Date: Sat Jul 25 2026 - 06:19:44 EST


From: Pu Lehui <pulehui@xxxxxxxxxx>

If a subprogram fails to JIT in jit_subprogs(), previously JITed
subprograms are freed. However, the generic bpf_jit_free() fails to
free their leftover jit_data, causing a memory leak.

Implement a custom bpf_jit_free() to free this data.

Fixes: 22de5d626231 ("parisc: Add eBPF JIT compiler glue code and Makefile")
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Signed-off-by: Pu Lehui <pulehui@xxxxxxxxxx>
---
arch/parisc/net/bpf_jit_core.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/parisc/net/bpf_jit_core.c b/arch/parisc/net/bpf_jit_core.c
index 172770132440..11e13ad6bc50 100644
--- a/arch/parisc/net/bpf_jit_core.c
+++ b/arch/parisc/net/bpf_jit_core.c
@@ -178,6 +178,25 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
goto out_offset;
}

+void bpf_jit_free(struct bpf_prog *fp)
+{
+ if (fp->jited) {
+ struct bpf_jit_data *jit_data = fp->aux->jit_data;
+ struct bpf_binary_header *hdr = bpf_jit_binary_hdr(fp);
+
+ /* Cleanup for earlier subprogs if jit_subprogs() aborts */
+ if (jit_data) {
+ kfree(jit_data->ctx.offset);
+ kfree(jit_data);
+ }
+
+ bpf_jit_binary_free(hdr);
+ WARN_ON_ONCE(!bpf_prog_kallsyms_verify_off(fp));
+ }
+
+ bpf_prog_unlock_free(fp);
+}
+
u64 hppa_div64(u64 div, u64 divisor)
{
div = div64_u64(div, divisor);
--
2.34.1