netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andriin@fb.com>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>, <ast@fb.com>,
	<daniel@iogearbox.net>
Cc: <andrii.nakryiko@gmail.com>, <kernel-team@fb.com>,
	Andrii Nakryiko <andriin@fb.com>, KP Singh <kpsingh@google.com>
Subject: [PATCH v2 bpf-next 08/11] libbpf: fix huge memory leak in libbpf_find_vmlinux_btf_id()
Date: Tue, 28 Apr 2020 18:21:08 -0700	[thread overview]
Message-ID: <20200429012111.277390-9-andriin@fb.com> (raw)
In-Reply-To: <20200429012111.277390-1-andriin@fb.com>

BTF object wasn't freed.

Cc: KP Singh <kpsingh@google.com>
Fixes: a6ed02cac690 ("libbpf: Load btf_vmlinux only once per object.")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/lib/bpf/libbpf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 8e1dc6980fac..a0f943e6b7bb 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -6672,6 +6672,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)) {
@@ -6679,7 +6680,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)
-- 
2.24.1


  parent reply	other threads:[~2020-04-29  1:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29  1:21 [PATCH v2 bpf-next 00/11] Fix libbpf and selftest issues detected by ASAN Andrii Nakryiko
2020-04-29  1:21 ` [PATCH v2 bpf-next 01/11] selftests/bpf: ensure test flavors use correct skeletons Andrii Nakryiko
2020-04-29  1:21 ` [PATCH v2 bpf-next 02/11] selftests/bpf: add SAN_CFLAGS param to selftests build to allow sanitizers Andrii Nakryiko
2020-04-29  1:21 ` [PATCH v2 bpf-next 03/11] selftests/bpf: convert test_hashmap into test_progs test Andrii Nakryiko
2020-04-29  1:21 ` [PATCH v2 bpf-next 04/11] libbpf: fix memory leak and possible double-free in hashmap__clear Andrii Nakryiko
2020-04-29  1:21 ` [PATCH v2 bpf-next 05/11] selftests/bpf: fix memory leak in test selector Andrii Nakryiko
2020-04-29  1:21 ` [PATCH v2 bpf-next 06/11] selftests/bpf: fix memory leak in extract_build_id() Andrii Nakryiko
2020-04-29  1:21 ` [PATCH v2 bpf-next 07/11] selftests/bpf: fix invalid memory reads in core_relo selftest Andrii Nakryiko
2020-04-29  1:21 ` Andrii Nakryiko [this message]
2020-04-29  1:21 ` [PATCH v2 bpf-next 09/11] selftests/bpf: disable ASAN instrumentation for mmap()'ed memory read Andrii Nakryiko
2020-04-29  1:21 ` [PATCH v2 bpf-next 10/11] selftests/bpf: fix bpf_link leak in ns_current_pid_tgid selftest Andrii Nakryiko
2020-04-29  1:21 ` [PATCH v2 bpf-next 11/11] selftests/bpf: add runqslower binary to .gitignore Andrii Nakryiko
2020-04-29  2:56 ` [PATCH v2 bpf-next 00/11] Fix libbpf and selftest issues detected by ASAN Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200429012111.277390-9-andriin@fb.com \
    --to=andriin@fb.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=kpsingh@google.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).