bpf: Add missing btf_put to register_btf_id_dtor_kfuncs
Jiri Olsa
reviewerPATCH 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.
--- 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
Quoted 4 lines · Jiri Olsa
We take the BTF reference before we register dtors and we need to put it back when it's done.
Quoted 8 lines
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 5ce937d613a4 ("bpf: Populate pairs of btf_id and destructor kfunc in btf")Signed-off-by Jiri Olsa <[email protected]>---
Thanks for the fix.
Quoted 22 lines
kernel/bpf/btf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/bpf/btf.c +2
-3@@ -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; } --2.39.0
Quoted 10 lines · Kumar Kartikeya Dwivedi
Quoted 8 lines · Jiri Olsa
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.
Quoted 7 lines
Quoted 4 lines
Cc Kumar Kartikeya Dwivedi <[email protected]>Fixes 5ce937d613a4 ("bpf: Populate pairs of btf_id and destructor kfunc in btf")Signed-off-by Jiri Olsa <[email protected]>---
Thanks for the fix.
Jiri,
lore and patchwork didn't receive this patch.
Only Kumar's reply is in lore.
Please resend.