cls_flower: Fix incorrect idr release when failing to modify rule
authorPaul Blakey <paulb@mellanox.com>
Wed, 30 May 2018 08:29:15 +0000 (11:29 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 31 May 2018 19:18:44 +0000 (15:18 -0400)
When we fail to modify a rule, we incorrectly release the idr handle
of the unmodified old rule.

Fix that by checking if we need to release it.

Fixes: fe2502e49b58 ("net_sched: remove cls_flower idr on failure")
Reported-by: Vlad Buslov <vladbu@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_flower.c

index d964e60c730eafb79a8a9437325e14c8d6288e40..c79f6e71512e5ec48b48ae7ec87a77c1c3ddd469 100644 (file)
@@ -977,7 +977,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
        return 0;
 
 errout_idr:
-       if (fnew->handle)
+       if (!fold)
                idr_remove(&head->handle_idr, fnew->handle);
 errout:
        tcf_exts_destroy(&fnew->exts);