: libbpf: fixing leak when kernel does not support btf
Subsystems (4)
PATCH v2 1/1 : libbpf: fixing leak when kernel does not support btf
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
v1->v2:
- adding netdev to cc
Signed-off-by Nikita V. Shirokov <[email protected]>
--- tools/lib/bpf/libbpf.c | 2 ++ 1 file changed, 2 insertions(+)
tools/lib/bpf/libbpf.c +2 -0
@@ -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 ) {
Signature · 1 line
2.17.1