mirror-linux/tools/lib/bpf
Hao Luo d5feaef143 libbpf: Free btf_vmlinux when closing bpf_object
[ Upstream commit 29d67fdebc ]

I hit a memory leak when testing bpf_program__set_attach_target().
Basically, set_attach_target() may allocate btf_vmlinux, for example,
when setting attach target for bpf_iter programs. But btf_vmlinux
is freed only in bpf_object_load(), which means if we only open
bpf object but not load it, setting attach target may leak
btf_vmlinux.

So let's free btf_vmlinux in bpf_object__close() anyway.

Signed-off-by: Hao Luo <haoluo@google.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230822193840.1509809-1-haoluo@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-23 11:11:03 +02:00
..
.gitignore
Build
Makefile
bpf.c
bpf.h
bpf_core_read.h
bpf_endian.h
bpf_gen_internal.h
bpf_helpers.h libbpf: fix offsetof() and container_of() to work with CO-RE 2023-07-19 16:21:04 +02:00
bpf_prog_linfo.c
bpf_tracing.h
btf.c
btf.h
btf_dump.c libbpf: btf_dump_type_data_check_overflow needs to consider BTF_MEMBER_BITFIELD_SIZE 2023-07-19 16:21:04 +02:00
gen_loader.c libbpf: Fix ld_imm64 copy logic for ksym in light skeleton. 2023-05-11 23:03:18 +09:00
hashmap.c
hashmap.h
libbpf.c libbpf: Free btf_vmlinux when closing bpf_object 2023-09-23 11:11:03 +02:00
libbpf.h
libbpf.map
libbpf.pc.template
libbpf_common.h
libbpf_errno.c
libbpf_internal.h
libbpf_legacy.h
libbpf_probes.c
libbpf_version.h
linker.c
netlink.c
nlattr.c
nlattr.h
relo_core.c
relo_core.h
ringbuf.c
skel_internal.h
str_error.c
str_error.h
strset.c
strset.h
usdt.bpf.h
usdt.c libbpf: Fix realloc API handling in zero-sized edge cases 2023-09-13 09:42:30 +02:00