From cadb9c9fdbc6a624d57b5ecdfd412b5800848703 Mon Sep 17 00:00:00 2001 From: Yotam Gigi Date: Tue, 31 Jan 2017 11:33:53 +0200 Subject: [PATCH 1/2] net/sched: act_sample: Fix error path in init Fix error path of in sample init, by releasing the tc hash in case of failure in psample_group creation. Fixes: 5c5670fae430 ("net/sched: Introduce sample tc action") Reported-by: Cong Wang Reviewed-by: Jiri Pirko Signed-off-by: Yotam Gigi Signed-off-by: David S. Miller --- net/sched/act_sample.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 39229756de07..02b67495829c 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -81,8 +81,11 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, s->rate = nla_get_u32(tb[TCA_SAMPLE_RATE]); s->psample_group_num = nla_get_u32(tb[TCA_SAMPLE_PSAMPLE_GROUP]); psample_group = psample_group_get(net, s->psample_group_num); - if (!psample_group) + if (!psample_group) { + if (ret == ACT_P_CREATED) + tcf_hash_release(*a, bind); return -ENOMEM; + } RCU_INIT_POINTER(s->psample_group, psample_group); if (tb[TCA_SAMPLE_TRUNC_SIZE]) { From f3b20313aef93f9cfda76fec2c05625f88510f18 Mon Sep 17 00:00:00 2001 From: Yotam Gigi Date: Tue, 31 Jan 2017 11:33:54 +0200 Subject: [PATCH 2/2] net/sched: act_psample: Remove unnecessary ASSERT_RTNL The ASSERT_RTNL is not necessary in the init function, as it does not touch any rtnl protected structures, as opposed to the mirred action which does have to hold a net device. Reported-by: Cong Wang Reviewed-by: Jiri Pirko Signed-off-by: Yotam Gigi Signed-off-by: David S. Miller --- net/sched/act_sample.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 02b67495829c..0b8217b4763f 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -76,7 +76,6 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, } s = to_sample(*a); - ASSERT_RTNL(); s->tcf_action = parm->action; s->rate = nla_get_u32(tb[TCA_SAMPLE_RATE]); s->psample_group_num = nla_get_u32(tb[TCA_SAMPLE_PSAMPLE_GROUP]);