netfilter: ipset: Don't call ip_nest_end needlessly in the error path
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Sat, 27 Apr 2013 19:02:59 +0000 (21:02 +0200)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 30 Sep 2013 19:33:25 +0000 (21:33 +0200)
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
net/netfilter/ipset/ip_set_bitmap_gen.h
net/netfilter/ipset/ip_set_hash_gen.h
net/netfilter/ipset/ip_set_list_set.c

index 25243379b887e5724d147cac0afedab58a1dec61..f6af97cf8d3e4fa6a39aef4053cffa6ae1b92861 100644 (file)
@@ -228,11 +228,11 @@ mtype_list(const struct ip_set *set,
 
 nla_put_failure:
        nla_nest_cancel(skb, nested);
-       ipset_nest_end(skb, adt);
        if (unlikely(id == first)) {
                cb->args[2] = 0;
                return -EMSGSIZE;
        }
+       ipset_nest_end(skb, adt);
        return 0;
 }
 
index 707bc520d629f311dd9978d2e0bf222719f71c82..7ff20ecbe185ce192137b198fad9bad1ff3aed5a 100644 (file)
@@ -909,13 +909,13 @@ mtype_list(const struct ip_set *set,
 
 nla_put_failure:
        nlmsg_trim(skb, incomplete);
-       ipset_nest_end(skb, atd);
        if (unlikely(first == cb->args[2])) {
                pr_warning("Can't list set %s: one bucket does not fit into "
                           "a message. Please report it!\n", set->name);
                cb->args[2] = 0;
                return -EMSGSIZE;
        }
+       ipset_nest_end(skb, atd);
        return 0;
 }
 
index 979b8c90e42201c656faf914e38b4b30bac2d298..68299ee158470801a7a43293a040d0d4a51240a0 100644 (file)
@@ -550,11 +550,11 @@ finish:
 
 nla_put_failure:
        nla_nest_cancel(skb, nested);
-       ipset_nest_end(skb, atd);
        if (unlikely(i == first)) {
                cb->args[2] = 0;
                return -EMSGSIZE;
        }
+       ipset_nest_end(skb, atd);
        return 0;
 }