]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables: Don't leak iter in error path of __nft_chain_zero_counters()
authorPhil Sutter <phil@nwl.cc>
Mon, 13 May 2019 17:12:24 +0000 (19:12 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 15 May 2019 15:14:40 +0000 (17:14 +0200)
If batch_rule_add() fails, this function leaked the rule iterator
object.

Fixes: 4c54c892443c2 ("xtables: Catch errors when zeroing rule rounters")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/nft.c

index 6354b7e8e72fecebf31c9c68a576b3b6ebb14fe8..dab1db59ec971f05fe0cd7dced7c279a6f35029d 100644 (file)
@@ -3374,8 +3374,10 @@ static int __nft_chain_zero_counters(struct nftnl_chain *c, void *data)
                         * rule based on its handle only.
                         */
                        nftnl_rule_unset(r, NFTNL_RULE_POSITION);
-                       if (!batch_rule_add(h, NFT_COMPAT_RULE_REPLACE, r))
+                       if (!batch_rule_add(h, NFT_COMPAT_RULE_REPLACE, r)) {
+                               nftnl_rule_iter_destroy(iter);
                                return -1;
+                       }
                }
                r = nftnl_rule_iter_next(iter);
        }