On Fri, Feb 02, 2024 at 05:18:48PM +0800, Geliang Tang wrote: > From: Geliang Tang <tanggeliang@xxxxxxxxxx> > > Similar to the handling in the functions __register_btf_kfunc_id_set() and > register_btf_id_dtor_kfuncs(), this patch adds CONFIG_DEBUG_INFO_BTF and > CONFIG_DEBUG_INFO_BTF_MODULES checks for __register_bpf_struct_ops() on > error path too when btf_get_module_btf() returns NULL. > > Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx> > --- > kernel/bpf/btf.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > index ef380e546952..381676add335 100644 > --- a/kernel/bpf/btf.c > +++ b/kernel/bpf/btf.c > @@ -8880,8 +8880,15 @@ int __register_bpf_struct_ops(struct bpf_struct_ops *st_ops) > int err = 0; > > btf = btf_get_module_btf(st_ops->owner); > - if (!btf) > - return -EINVAL; > + if (!btf) { > + if (!st_ops->owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) { > + pr_err("missing vmlinux BTF, cannot register structs\n"); > + return -EINVAL; > + } > + if (st_ops->owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES)) > + pr_warn("missing module BTF, cannot register structs\n"); > + return 0; given that we have the same code in 2 other functions would it make sense to add function for that? jirka > + } > > log = kzalloc(sizeof(*log), GFP_KERNEL | __GFP_NOWARN); > if (!log) { > -- > 2.40.1 >