mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
libbpf: Add bpf_object_cleanup_btf function
Adding bpf_object_cleanup_btf function to cleanup btf objects. It will be used in following changes. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20260606123955.345967-18-jolsa@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
8abecdafd5
commit
fe9c8cb2b5
@@ -8941,13 +8941,10 @@ static void bpf_object_unpin(struct bpf_object *obj)
|
||||
bpf_map__unpin(&obj->maps[i], NULL);
|
||||
}
|
||||
|
||||
static void bpf_object_post_load_cleanup(struct bpf_object *obj)
|
||||
static void bpf_object_cleanup_btf(struct bpf_object *obj)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* clean up fd_array */
|
||||
zfree(&obj->fd_array);
|
||||
|
||||
/* clean up module BTFs */
|
||||
for (i = 0; i < obj->btf_module_cnt; i++) {
|
||||
close(obj->btf_modules[i].fd);
|
||||
@@ -8955,6 +8952,8 @@ static void bpf_object_post_load_cleanup(struct bpf_object *obj)
|
||||
free(obj->btf_modules[i].name);
|
||||
}
|
||||
obj->btf_module_cnt = 0;
|
||||
obj->btf_module_cap = 0;
|
||||
obj->btf_modules_loaded = false;
|
||||
zfree(&obj->btf_modules);
|
||||
|
||||
/* clean up vmlinux BTF */
|
||||
@@ -8962,6 +8961,15 @@ static void bpf_object_post_load_cleanup(struct bpf_object *obj)
|
||||
obj->btf_vmlinux = NULL;
|
||||
}
|
||||
|
||||
static void bpf_object_post_load_cleanup(struct bpf_object *obj)
|
||||
{
|
||||
/* clean up fd_array */
|
||||
zfree(&obj->fd_array);
|
||||
|
||||
/* clean up BTF */
|
||||
bpf_object_cleanup_btf(obj);
|
||||
}
|
||||
|
||||
static int bpf_object_prepare(struct bpf_object *obj, const char *target_btf_path)
|
||||
{
|
||||
int err;
|
||||
|
||||
Reference in New Issue
Block a user