Skip to contentSkip to conversation

Question about error handling in btf_populate_kfunc_set()

BPF [email protected] 1 participant 1 message Nov 8 BPF

lore
Share & tools
lore
#0 lore raw

Hi,

While reviewing the Smatch warning in btf_populate_kfunc_set() in kernel/bpf/btf.c, I noticed that several error paths call btf_free_kfunc_set_tab(btf) through the common end label.

This function frees the entire kfunc set table, including sets that may have been successfully registered by earlier calls.

For example, if krealloc() fails while adding a new set, the original allocation remains valid, but the error path subsequently frees the complete table.

I also noticed that kfunc sets are registered from multiple initialization functions, including a separate init_subsystem() registration in net/core/filter.c.

Is it intentional that a failure during a subsequent kfunc registration destroys all previously registered kfunc sets for the same BTF object, or should the error handling preserve the existing registrations and roll back only the current registration?

I haven't established a reproducible failure, so I would appreciate your clarification on the intended behavior.

Thanks,
Shahid.