diff options
| author | Andrii Nakryiko <[email protected]> | 2020-04-29 01:21:08 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2020-04-29 02:48:05 +0000 |
| commit | 3521ffa2ee9a48c3236c93f54ae11c074490ebce (patch) | |
| tree | 77d887266884f290af1c02cdb5ec7fab10157896 /tools/lib/bpf/libbpf.c | |
| parent | selftests/bpf: Fix invalid memory reads in core_relo selftest (diff) | |
| download | kernel-3521ffa2ee9a48c3236c93f54ae11c074490ebce.tar.gz kernel-3521ffa2ee9a48c3236c93f54ae11c074490ebce.zip | |
libbpf: Fix huge memory leak in libbpf_find_vmlinux_btf_id()
BTF object wasn't freed.
Fixes: a6ed02cac690 ("libbpf: Load btf_vmlinux only once per object.")
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Cc: KP Singh <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 445ee903f9cd..d86ff8214b96 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -6934,6 +6934,7 @@ int libbpf_find_vmlinux_btf_id(const char *name, enum bpf_attach_type attach_type) { struct btf *btf; + int err; btf = libbpf_find_kernel_btf(); if (IS_ERR(btf)) { @@ -6941,7 +6942,9 @@ int libbpf_find_vmlinux_btf_id(const char *name, 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) |
