Skip to content

Commit 74bc3a5

Browse files
olsajiriAlexei Starovoitov
authored and
Alexei Starovoitov
committed
bpf: Add missing btf_put to register_btf_id_dtor_kfuncs
We take the BTF reference before we register dtors and we need to put it back when it's done. We probably won't se a problem with kernel BTF, but module BTF would stay loaded (because of the extra ref) even when its module is removed. Cc: Kumar Kartikeya Dwivedi <[email protected]> Fixes: 5ce937d ("bpf: Populate pairs of btf_id and destructor kfunc in btf") Acked-by: Kumar Kartikeya Dwivedi <[email protected]> Signed-off-by: Jiri Olsa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 2eecf81 commit 74bc3a5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: kernel/bpf/btf.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -7782,9 +7782,9 @@ int register_btf_id_dtor_kfuncs(const struct btf_id_dtor_kfunc *dtors, u32 add_c
77827782

77837783
sort(tab->dtors, tab->cnt, sizeof(tab->dtors[0]), btf_id_cmp_func, NULL);
77847784

7785-
return 0;
77867785
end:
7787-
btf_free_dtor_kfunc_tab(btf);
7786+
if (ret)
7787+
btf_free_dtor_kfunc_tab(btf);
77887788
btf_put(btf);
77897789
return ret;
77907790
}

0 commit comments

Comments
 (0)