bpf: Fix memleak in aux->func_info and aux->btf
authorMartin KaFai Lau <kafai@fb.com>
Sun, 2 Dec 2018 01:08:44 +0000 (17:08 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 2 Dec 2018 17:12:58 +0000 (09:12 -0800)
The aux->func_info and aux->btf are leaked in the error out cases
during bpf_prog_load().  This patch fixes it.

Fixes: 2821b34950ef ("bpf: btf: support proper non-jit func info")
Cc: Yonghong Song <yhs@fb.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/syscall.c

index f9554d9a14e18840c61436ce32f58070c88a690f..4445d0d084d88f2b193a43369fab037920848e9c 100644 (file)
@@ -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: