bpf: Add missing btf_put to register_btf_id_dtor_kfuncs
authorJiri Olsa <jolsa@kernel.org>
Fri, 20 Jan 2023 12:21:48 +0000 (13:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2023 10:28:01 +0000 (11:28 +0100)
commitd5c7a2ab5e1f7c8cfaec8255aaed5e541d8f512a
treeeb9447b2913a5f281fdb407cba4b170fc0257879
parentd52f34784e4e2f6e77671a9f104d8a69a3b5d24c
bpf: Add missing btf_put to register_btf_id_dtor_kfuncs

[ Upstream commit 74bc3a5acc82f020d2e126f56c535d02d1e74e37 ]

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 <memxor@gmail.com>
Fixes: 5ce937d613a4 ("bpf: Populate pairs of btf_id and destructor kfunc in btf")
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20230120122148.1522359-1-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/btf.c