diff --git a/include/net/psample.h b/include/net/psample.h index 9b80f814ab043b733ec3efbcb0c30f9e1f690815..94cb37a7bf7569c78bbad36f225fa1f90c782fd5 100644 --- a/include/net/psample.h +++ b/include/net/psample.h @@ -12,6 +12,7 @@ struct psample_group { u32 group_num; u32 refcount; u32 seq; + struct rcu_head rcu; }; struct psample_group *psample_group_get(struct net *net, u32 group_num); diff --git a/net/psample/psample.c b/net/psample/psample.c index 64f95624f21939c946e0bb256a40d825588e0fd2..4cea353221da7b2919017b2493dc548b0f0fe000 100644 --- a/net/psample/psample.c +++ b/net/psample/psample.c @@ -156,7 +156,7 @@ static void psample_group_destroy(struct psample_group *group) { psample_group_notify(group, PSAMPLE_CMD_DEL_GROUP); list_del(&group->list); - kfree(group); + kfree_rcu(group, rcu); } static struct psample_group * diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index ac37654ca2922dbcd80daa30f7447c7f54784020..34ff6c30d1e6d5b7b3e7c68720f2e039b0043854 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -99,7 +99,8 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, s->tcf_action = parm->action; s->rate = rate; s->psample_group_num = psample_group_num; - RCU_INIT_POINTER(s->psample_group, psample_group); + rcu_swap_protected(s->psample_group, psample_group, + lockdep_is_held(&s->tcf_lock)); if (tb[TCA_SAMPLE_TRUNC_SIZE]) { s->truncate = true; @@ -107,6 +108,8 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, } spin_unlock_bh(&s->tcf_lock); + if (psample_group) + psample_group_put(psample_group); if (ret == ACT_P_CREATED) tcf_idr_insert(tn, *a); return ret;