diff mbox series

[RFC,1/5] net/sched: fix refcount leak when 'goto_chain' is used

Message ID 4bb07d66c377864996d5e53356026e339b0b28d4.1550271080.git.dcaratti@redhat.com
State RFC
Delegated to: David Miller
Headers show
Series net/sched: validate the control action with all the other parameters | expand

Commit Message

Davide Caratti Feb. 15, 2019, 11:06 p.m. UTC
when replacing valid 'goto chain' actions with another valid 'goto chain'
action, the kernel leaks chain->action_refcnt and chain->refcnt. Since we
unconditionally take the refcount again, if the control action is a 'goto
chain', we can just drop them after ->init() has ended successfully.

Fixes: db50514f9a9c ("net: sched: add termination action to allow goto chain")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
 net/sched/act_api.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series


diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index d4b8355737d8..91d79fac8cb2 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -907,6 +907,11 @@  struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
 	if (err != ACT_P_CREATED)
+	if (a->goto_chain) {
+		tcf_action_goto_chain_fini(a);
+		a->goto_chain = NULL;
+	}
 	if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN)) {
 		err = tcf_action_goto_chain_init(a, tp);
 		if (err) {