On Mon, May 23, 2022 at 07:15:03PM -0700, Stanislav Fomichev wrote: > > > + return; > > > + > > > + WARN_ON_ONCE(__bpf_trampoline_unlink_prog(&shim_link->tramp_link, shim_link->tr)); > > > + kfree(shim_link); > > How about shim_link->tramp_link.link.prog, is the prog freed ? > > > > Considering the bpf_link_put() does bpf_prog_put(link->prog). > > Is there a reason the bpf_link_put() not used and needs to > > manage its own shim_link->refcnt here ? > > Good catch, I've missed the bpf_prog_put(link->prog) part. Let me see > if I can use the link's refcnt, it seems like I can define my own > link->ops->dealloc to call __bpf_trampoline_unlink_prog and the rest > will be taken care of. >From looking at bpf_link_free(), link->ops->release may be a better one because the link->ops->release() will still need to use the shim_prog (e.g. shim_prog->aux->cgroup_atype).