]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netfilter: nf_tables: fix leaks in error path of nf_tables_newchain()
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 29 Jan 2015 18:08:09 +0000 (19:08 +0100)
committerLuis Henriques <luis.henriques@canonical.com>
Thu, 12 Mar 2015 15:32:26 +0000 (15:32 +0000)
commit f5553c19ff9058136e7082c0b1f4268e705ea538 upstream.

Release statistics and module refcount on memory allocation problems.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
net/netfilter/nf_tables_api.c

index fe551ca01a98114e3782720dc09e460098c87670..e1cf0f89748d8df049db12a0206ea73d31dbcdc5 100644 (file)
@@ -1034,8 +1034,10 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb,
                nft_ctx_init(&ctx, skb, nlh, afi, table, chain, nla);
                trans = nft_trans_alloc(&ctx, NFT_MSG_NEWCHAIN,
                                        sizeof(struct nft_trans_chain));
-               if (trans == NULL)
+               if (trans == NULL) {
+                       free_percpu(stats);
                        return -ENOMEM;
+               }
 
                nft_trans_chain_stats(trans) = stats;
                nft_trans_chain_update(trans) = true;
@@ -1091,8 +1093,10 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb,
                hookfn = type->hooks[hooknum];
 
                basechain = kzalloc(sizeof(*basechain), GFP_KERNEL);
-               if (basechain == NULL)
+               if (basechain == NULL) {
+                       module_put(type->owner);
                        return -ENOMEM;
+               }
 
                if (nla[NFTA_CHAIN_COUNTERS]) {
                        stats = nft_stats_alloc(nla[NFTA_CHAIN_COUNTERS]);