On Wed, Jun 17, 2020 at 02:15:38PM -0700, Yonghong Song wrote: [ ... ] > +static int bpf_iter_init_tcp(void *priv_data) > +{ > + struct tcp_iter_state *st = priv_data; > + struct tcp_seq_afinfo *afinfo; > + int ret; > + > + afinfo = kmalloc(sizeof(*afinfo), GFP_USER | __GFP_NOWARN); > + if (!afinfo) > + return -ENOMEM; > + > + afinfo->family = AF_UNSPEC; > + st->bpf_seq_afinfo = afinfo; > + ret = bpf_iter_init_seq_net(priv_data); > + if (ret) > + kfree(afinfo); st->bpf_seq_afinfo has already been initialized. bpf_iter_fini_tcp() (and iter_release()) will not be called? just want to ensure. > + return ret; > +} > + > +static void bpf_iter_fini_tcp(void *priv_data) > +{ > + struct tcp_iter_state *st = priv_data; > + > + kfree(st->bpf_seq_afinfo); > + bpf_iter_fini_seq_net(priv_data); > +}