]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - net/sched/act_sample.c
net: sched: act_sample: fix psample group handling on overwrite
[mirror_ubuntu-bionic-kernel.git] / net / sched / act_sample.c
index a5592aba043555449bad1641efc5af7d3c03c578..9ca8924dcd5fe04ae3a5cea2cafd1864b807a356 100644 (file)
@@ -92,13 +92,16 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla,
                        tcf_idr_release(*a, bind);
                return -ENOMEM;
        }
-       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;
                s->trunc_size = nla_get_u32(tb[TCA_SAMPLE_TRUNC_SIZE]);
        }
 
+       if (psample_group)
+               psample_group_put(psample_group);
        if (ret == ACT_P_CREATED)
                tcf_idr_insert(tn, *a);
        return ret;