diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2015-03-17 14:53:23 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2015-03-18 06:57:31 -0400 |
commit | ffdb210eb415501c289f6becafb54fe2f4535efa (patch) | |
tree | 896a41492e8d6845cc7d061ca5f165b40cbba68c /net | |
parent | 1ca9e41770cba46dcc7c2a9c6ac28350ed866695 (diff) |
netfilter: nf_tables: consolidate error path of nf_tables_newtable()
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/nf_tables_api.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index ea51833c8f5a..a072d8769b9b 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c | |||
@@ -687,11 +687,10 @@ static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb, | |||
687 | if (!try_module_get(afi->owner)) | 687 | if (!try_module_get(afi->owner)) |
688 | return -EAFNOSUPPORT; | 688 | return -EAFNOSUPPORT; |
689 | 689 | ||
690 | err = -ENOMEM; | ||
690 | table = kzalloc(sizeof(*table), GFP_KERNEL); | 691 | table = kzalloc(sizeof(*table), GFP_KERNEL); |
691 | if (table == NULL) { | 692 | if (table == NULL) |
692 | module_put(afi->owner); | 693 | goto err1; |
693 | return -ENOMEM; | ||
694 | } | ||
695 | 694 | ||
696 | nla_strlcpy(table->name, name, NFT_TABLE_MAXNAMELEN); | 695 | nla_strlcpy(table->name, name, NFT_TABLE_MAXNAMELEN); |
697 | INIT_LIST_HEAD(&table->chains); | 696 | INIT_LIST_HEAD(&table->chains); |
@@ -700,13 +699,16 @@ static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb, | |||
700 | 699 | ||
701 | nft_ctx_init(&ctx, skb, nlh, afi, table, NULL, nla); | 700 | nft_ctx_init(&ctx, skb, nlh, afi, table, NULL, nla); |
702 | err = nft_trans_table_add(&ctx, NFT_MSG_NEWTABLE); | 701 | err = nft_trans_table_add(&ctx, NFT_MSG_NEWTABLE); |
703 | if (err < 0) { | 702 | if (err < 0) |
704 | kfree(table); | 703 | goto err2; |
705 | module_put(afi->owner); | 704 | |
706 | return err; | ||
707 | } | ||
708 | list_add_tail_rcu(&table->list, &afi->tables); | 705 | list_add_tail_rcu(&table->list, &afi->tables); |
709 | return 0; | 706 | return 0; |
707 | err2: | ||
708 | kfree(table); | ||
709 | err1: | ||
710 | module_put(afi->owner); | ||
711 | return err; | ||
710 | } | 712 | } |
711 | 713 | ||
712 | static int nft_flush_table(struct nft_ctx *ctx) | 714 | static int nft_flush_table(struct nft_ctx *ctx) |