]> 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)
commitbf20d315a7b9f6d69f43d185a528d6fd99f9daeb
treef3a1592c19c8d4b1502b06a352d598a24b498b82
parenta7aa9a85fd5650b14c1796c09931922529860a3a
libbpf: Fix memory leak and optimize BTF sanitization

Coverity's static analysis helpfully reported a memory leak introduced by
d83aa0ed05f7 ("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: d83aa0ed05f7 ("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