net_sched: remove cls_flower idr on failure
authorCong Wang <xiyou.wangcong@gmail.com>
Wed, 20 Sep 2017 16:18:45 +0000 (09:18 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Sep 2017 22:13:52 +0000 (15:13 -0700)
Fixes: c15ab236d69d ("net/sched: Change cls_flower to use IDR")
Cc: Chris Mi <chrism@mellanox.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_flower.c

index 1a267e77c6de93ad58fd609426d3daef27f39c54..d230cb4c809454137968be4bb1537d92bc8ebc5d 100644 (file)
@@ -922,28 +922,28 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
 
                if (!tc_flags_valid(fnew->flags)) {
                        err = -EINVAL;
-                       goto errout;
+                       goto errout_idr;
                }
        }
 
        err = fl_set_parms(net, tp, fnew, &mask, base, tb, tca[TCA_RATE], ovr);
        if (err)
-               goto errout;
+               goto errout_idr;
 
        err = fl_check_assign_mask(head, &mask);
        if (err)
-               goto errout;
+               goto errout_idr;
 
        if (!tc_skip_sw(fnew->flags)) {
                if (!fold && fl_lookup(head, &fnew->mkey)) {
                        err = -EEXIST;
-                       goto errout;
+                       goto errout_idr;
                }
 
                err = rhashtable_insert_fast(&head->ht, &fnew->ht_node,
                                             head->ht_params);
                if (err)
-                       goto errout;
+                       goto errout_idr;
        }
 
        if (!tc_skip_hw(fnew->flags)) {
@@ -952,7 +952,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
                                           &mask.key,
                                           fnew);
                if (err)
-                       goto errout;
+                       goto errout_idr;
        }
 
        if (!tc_in_hw(fnew->flags))
@@ -981,6 +981,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
        kfree(tb);
        return 0;
 
+errout_idr:
+       if (fnew->handle)
+               idr_remove_ext(&head->handle_idr, fnew->handle);
 errout:
        tcf_exts_destroy(&fnew->exts);
        kfree(fnew);