]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: Avoid memleak in error path of nft_cmd_new()
authorPhil Sutter <phil@nwl.cc>
Wed, 2 Jun 2021 09:55:20 +0000 (11:55 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 7 Jun 2021 12:50:27 +0000 (14:50 +0200)
If rule allocation fails, free the allocated 'cmd' before returning to
caller.

Fixes: a7f1e208cdf9c ("nft: split parsing from netlink commands")
Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/nft-cmd.c

index f2b935c57dab401d366c00e7bb0cc651aa2cfde7..c3f6c14e0b99e729482f7d0349192592e6fa2b17 100644 (file)
@@ -35,8 +35,10 @@ struct nft_cmd *nft_cmd_new(struct nft_handle *h, int command,
 
        if (state) {
                rule = nft_rule_new(h, chain, table, state);
-               if (!rule)
+               if (!rule) {
+                       nft_cmd_free(cmd);
                        return NULL;
+               }
 
                cmd->obj.rule = rule;