From: Yonghong Song <yhs@fb.com>
To: "Nikita V. Shirokov" <tehnerd@tehnerd.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH v3 bpf]: libbpf: fixing leak when kernel does not support btf
Date: Fri, 8 Mar 2019 05:32:14 +0000 [thread overview]
Message-ID: <220b177a-bf93-7fbe-9550-66dcbbf847d0@fb.com> (raw)
In-Reply-To: <20190308051814.19218-1-tehnerd@tehnerd.com>
On 3/7/19 9:18 PM, Nikita V. Shirokov wrote:
> we could end up in situation when we have object file w/ all btf
> info but kernel does not support btf yet. in this situation currently
> libbpf just set obj->btf to NULL w/o freeing it first.
> this patch if fixing it by making sure to run btf__free first
>
> v2->v3:
> - adding "Fixes" tag
>
> v1->v2:
> - adding netdev to cc
>
> Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
> Signed-off-by: Nikita V. Shirokov <tehnerd@tehnerd.com>
Acked-by: Yonghong Song <yhs@fb.com>
> ---
> tools/lib/bpf/libbpf.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index f5eb60379c8d..d5b830d60601 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -838,6 +838,8 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
> if (IS_ERR(obj->btf) || btf__load(obj->btf)) {
> pr_warning("Error loading ELF section %s: %ld. Ignored and continue.\n",
> BTF_ELF_SEC, PTR_ERR(obj->btf));
> + if (!IS_ERR(obj->btf))
> + btf__free(obj->btf);
> obj->btf = NULL;
> }
> } else if (strcmp(name, BTF_EXT_ELF_SEC) == 0) {
>
next prev parent reply other threads:[~2019-03-08 5:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 5:18 [PATCH v3 bpf]: libbpf: fixing leak when kernel does not support btf Nikita V. Shirokov
2019-03-08 5:32 ` Yonghong Song [this message]
2019-03-08 13:20 ` Daniel Borkmann
2019-03-08 16:45 ` Martin Lau
2019-03-08 20:23 ` Daniel Borkmann
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=220b177a-bf93-7fbe-9550-66dcbbf847d0@fb.com \
--to=yhs@fb.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
--cc=tehnerd@tehnerd.com \
/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