Commit 3521ffa2 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov

libbpf: Fix huge memory leak in libbpf_find_vmlinux_btf_id()

BTF object wasn't freed.

Fixes: a6ed02ca ("libbpf: Load btf_vmlinux only once per object.")
Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Cc: KP Singh <kpsingh@google.com>
Link: https://lore.kernel.org/bpf/20200429012111.277390-9-andriin@fb.com
parent 13c90849
...@@ -6934,6 +6934,7 @@ int libbpf_find_vmlinux_btf_id(const char *name, ...@@ -6934,6 +6934,7 @@ int libbpf_find_vmlinux_btf_id(const char *name,
enum bpf_attach_type attach_type) enum bpf_attach_type attach_type)
{ {
struct btf *btf; struct btf *btf;
int err;
btf = libbpf_find_kernel_btf(); btf = libbpf_find_kernel_btf();
if (IS_ERR(btf)) { if (IS_ERR(btf)) {
...@@ -6941,7 +6942,9 @@ int libbpf_find_vmlinux_btf_id(const char *name, ...@@ -6941,7 +6942,9 @@ int libbpf_find_vmlinux_btf_id(const char *name,
return -EINVAL; return -EINVAL;
} }
return __find_vmlinux_btf_id(btf, name, attach_type); err = __find_vmlinux_btf_id(btf, name, attach_type);
btf__free(btf);
return err;
} }
static int libbpf_find_prog_btf_id(const char *name, __u32 attach_prog_fd) static int libbpf_find_prog_btf_id(const char *name, __u32 attach_prog_fd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment