Skip to content

Commit

Permalink
bpf: Add missing btf_put to register_btf_id_dtor_kfuncs
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
olsajiri authored and Alexei Starovoitov committed Jan 20, 2023
1 parent 2eecf81 commit 74bc3a5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/bpf/btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7782,9 +7782,9 @@ int register_btf_id_dtor_kfuncs(const struct btf_id_dtor_kfunc *dtors, u32 add_c

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

return 0;
end:
btf_free_dtor_kfunc_tab(btf);
if (ret)
btf_free_dtor_kfunc_tab(btf);
btf_put(btf);
return ret;
}
Expand Down

0 comments on commit 74bc3a5

Please sign in to comment.