Projects
openEuler:24.03:SP1:Everything
libbpf
_service:tar_scm:backport-libbpf-Free-btf_vmlin...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:backport-libbpf-Free-btf_vmlinux-when-closing-bpf_object.patch of Package libbpf
From a687461867589b82a1cd4ee261aa374a687584b2 Mon Sep 17 00:00:00 2001 From: Hao Luo <haoluo@google.com> Date: Tue, 22 Aug 2023 12:38:40 -0700 Subject: [PATCH 1/1] libbpf: Free btf_vmlinux when closing bpf_object 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 --- src/libbpf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libbpf.c b/src/libbpf.c index b8afe2f..4c3967d 100644 --- a/src/libbpf.c +++ b/src/libbpf.c @@ -8423,6 +8423,7 @@ void bpf_object__close(struct bpf_object *obj) bpf_object__elf_finish(obj); bpf_object_unload(obj); btf__free(obj->btf); + btf__free(obj->btf_vmlinux); btf_ext__free(obj->btf_ext); for (i = 0; i < obj->nr_maps; i++) -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2