diff mbox series

[net,2/2] net: sched: fix static key imbalance in case of ingress/clsact_init error

Message ID 20171215114013.6425-3-jiri@resnulli.us
State Accepted, archived
Delegated to: David Miller
Headers show
Series net: sched: couple of fixes on ingress/clsact init error path | expand

Commit Message

Jiri Pirko Dec. 15, 2017, 11:40 a.m. UTC
From: Jiri Pirko <jiri@mellanox.com>

Move static key increments to the beginning of the init function
so they pair 1:1 with decrements in ingress/clsact_destroy,
which is called in case ingress/clsact_init fails.

Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/sched/sch_ingress.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Cong Wang Dec. 15, 2017, 7:18 p.m. UTC | #1
On Fri, Dec 15, 2017 at 3:40 AM, Jiri Pirko <jiri@resnulli.us> wrote:
> From: Jiri Pirko <jiri@mellanox.com>
>
> Move static key increments to the beginning of the init function
> so they pair 1:1 with decrements in ingress/clsact_destroy,
> which is called in case ingress/clsact_init fails.
>
> Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
David Miller Dec. 15, 2017, 8:44 p.m. UTC | #2
From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 15 Dec 2017 12:40:13 +0100

> From: Jiri Pirko <jiri@mellanox.com>
> 
> Move static key increments to the beginning of the init function
> so they pair 1:1 with decrements in ingress/clsact_destroy,
> which is called in case ingress/clsact_init fails.
> 
> Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Applied and queued up for -stable.
diff mbox series

Patch

diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index 5e1cd2e..fc1286f 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -68,6 +68,8 @@  static int ingress_init(struct Qdisc *sch, struct nlattr *opt)
 	struct net_device *dev = qdisc_dev(sch);
 	int err;
 
+	net_inc_ingress_queue();
+
 	mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress);
 
 	q->block_info.binder_type = TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
@@ -78,7 +80,6 @@  static int ingress_init(struct Qdisc *sch, struct nlattr *opt)
 	if (err)
 		return err;
 
-	net_inc_ingress_queue();
 	sch->flags |= TCQ_F_CPUSTATS;
 
 	return 0;
@@ -172,6 +173,9 @@  static int clsact_init(struct Qdisc *sch, struct nlattr *opt)
 	struct net_device *dev = qdisc_dev(sch);
 	int err;
 
+	net_inc_ingress_queue();
+	net_inc_egress_queue();
+
 	mini_qdisc_pair_init(&q->miniqp_ingress, sch, &dev->miniq_ingress);
 
 	q->ingress_block_info.binder_type = TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
@@ -192,9 +196,6 @@  static int clsact_init(struct Qdisc *sch, struct nlattr *opt)
 	if (err)
 		return err;
 
-	net_inc_ingress_queue();
-	net_inc_egress_queue();
-
 	sch->flags |= TCQ_F_CPUSTATS;
 
 	return 0;