net: cls_u32: catch all hardware offload errors
authorJakub Kicinski <jakub.kicinski@netronome.com>
Wed, 8 Jun 2016 19:11:03 +0000 (20:11 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 Jun 2016 04:43:14 +0000 (21:43 -0700)
Errors reported by u32_replace_hw_hnode() were not propagated.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_u32.c

index 27b99fd774d7dbe9f0fac333a03e02cc19c59600..54ab32a8ff4ca924341247fd591b94fd27a73bd1 100644 (file)
@@ -922,11 +922,17 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
                ht->divisor = divisor;
                ht->handle = handle;
                ht->prio = tp->prio;
+
+               err = u32_replace_hw_hnode(tp, ht, flags);
+               if (err) {
+                       kfree(ht);
+                       return err;
+               }
+
                RCU_INIT_POINTER(ht->next, tp_c->hlist);
                rcu_assign_pointer(tp_c->hlist, ht);
                *arg = (unsigned long)ht;
 
-               u32_replace_hw_hnode(tp, ht, flags);
                return 0;
        }