]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Fix memory leak and optimize BTF sanitization
authorAndrii Nakryiko <andriin@fb.com>
Fri, 10 Jul 2020 01:10:23 +0000 (18:10 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 10 Jul 2020 14:24:35 +0000 (16:24 +0200)
commit5a220b41537c181b5e10dce215f512c4c341ba4b
treef3a1592c19c8d4b1502b06a352d598a24b498b82
parent1ed737a7cb1bf4366a85f71f2260fb015f7ef6d5
libbpf: Fix memory leak and optimize BTF sanitization

Coverity's static analysis helpfully reported a memory leak introduced by
475396048915 ("libbpf: Improve BTF sanitization handling"). While fixing it,
I realized that btf__new() already creates a memory copy, so there is no need
to do this. So this patch also fixes misleading btf__new() signature to make
data into a `const void *` input parameter. And it avoids unnecessary memory
allocation and copy in BTF sanitization code altogether.

Fixes: 475396048915 ("libbpf: Improve BTF sanitization handling")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200710011023.1655008-1-andriin@fb.com
tools/lib/bpf/btf.c
tools/lib/bpf/btf.h
tools/lib/bpf/libbpf.c