Skip to contentSkip to conversation

bpf: Fix memleak in aux->func_info and aux->btf

PATCH Applied Martin KaFai Lau 2 participants 2 messages Dec 2, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Fix memleak in aux->func_info and aux->btf

The aux->func_info and aux->btf are leaked in the error out cases during bpf_prog_load(). This patch fixes it.

Fixes ba64e7d85252 ("bpf: btf: support proper non-jit func info")
Cc Yonghong Song <[email protected]>
---
 kernel/bpf/syscall.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/bpf/syscall.c +2 -0
index f9554d9a14e1..4445d0d084d8 100644
@@ -1560,6 +1560,8 @@ static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr)
 	return err;
 
 free_used_maps:
+	kvfree(prog->aux->func_info);
+	btf_put(prog->aux->btf);
 	bpf_prog_kallsyms_del_subprogs(prog);
 	free_used_maps(prog->aux);
 free_prog:
Signature · 1 line
2.17.1