net: sched: fix unbalance in the error path of tca_action_flush()
authorDavide Caratti <dcaratti@redhat.com>
Thu, 15 Feb 2018 14:50:57 +0000 (15:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Feb 2018 20:43:17 +0000 (15:43 -0500)
When tca_action_flush() calls the action walk() and gets an error,
a successful call to nla_nest_start() is not followed by a call to
nla_nest_cancel(). It's harmless, as the skb is freed in the error
path - but it's worth to fix this unbalance.

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_api.c

index 4886ea4a7d6e790660d4d0a86ba021c88c488a4d..624995564e5abb2ef352de95b40f78b72e819940 100644 (file)
@@ -938,8 +938,10 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
                goto out_module_put;
 
        err = ops->walk(net, skb, &dcb, RTM_DELACTION, ops);
-       if (err <= 0)
+       if (err <= 0) {
+               nla_nest_cancel(skb, nest);
                goto out_module_put;
+       }
 
        nla_nest_end(skb, nest);