bpf: Add missing btf_put to register_btf_id_dtor_kfuncs
Jiri Olsa
reviewerPATCH v2 1/1 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.
---
v2 changes:
- resend and added Kumar's ack
kernel/bpf/btf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/btf.c +2 -2
@@ -7782,9 +7782,9 @@ int register_btf_id_dtor_kfuncs(const struct btf_id_dtor_kfunc *dtors, u32 add_csort (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; }
Signature · 1 line
2.39.0
This patch was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:
Quoted 8 lines · On Fri, 20 Jan 2023 13:21:48 +0100 you wrote:
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.
[...]
Here is the summary with links:
- [PATCHv2,bpf] bpf: Add missing btf_put to register_btf_id_dtor_kfuncs
https://git.kernel.org/bpf/bpf/c/74bc3a5acc82
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html