netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 4/8] netfilter: nf_tables: consolidate error path of nf_tables_newtable()
Date: Mon, 23 Mar 2015 12:36:20 +0100	[thread overview]
Message-ID: <1427110584-5190-5-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1427110584-5190-1-git-send-email-pablo@netfilter.org>

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index ea51833..a072d87 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,
 	if (!try_module_get(afi->owner))
 		return -EAFNOSUPPORT;
 
+	err = -ENOMEM;
 	table = kzalloc(sizeof(*table), GFP_KERNEL);
-	if (table == NULL) {
-		module_put(afi->owner);
-		return -ENOMEM;
-	}
+	if (table == NULL)
+		goto err1;
 
 	nla_strlcpy(table->name, name, NFT_TABLE_MAXNAMELEN);
 	INIT_LIST_HEAD(&table->chains);
@@ -700,13 +699,16 @@ static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb,
 
 	nft_ctx_init(&ctx, skb, nlh, afi, table, NULL, nla);
 	err = nft_trans_table_add(&ctx, NFT_MSG_NEWTABLE);
-	if (err < 0) {
-		kfree(table);
-		module_put(afi->owner);
-		return err;
-	}
+	if (err < 0)
+		goto err2;
+
 	list_add_tail_rcu(&table->list, &afi->tables);
 	return 0;
+err2:
+	kfree(table);
+err1:
+	module_put(afi->owner);
+	return err;
 }
 
 static int nft_flush_table(struct nft_ctx *ctx)
-- 
1.7.10.4


  parent reply	other threads:[~2015-03-23 11:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23 11:36 [PATCH 0/8] Netfilter updates for net-next Pablo Neira Ayuso
2015-03-23 11:36 ` [PATCH 1/8] netfilter: bridge: query conntrack about skb dnat Pablo Neira Ayuso
2015-03-23 11:36 ` [PATCH 2/8] netfilter: bridge: remove BRNF_STATE_BRIDGED flag Pablo Neira Ayuso
2015-03-23 11:36 ` [PATCH 3/8] netfilter: Remove uses of seq_<foo> return values Pablo Neira Ayuso
2015-03-23 11:36 ` Pablo Neira Ayuso [this message]
2015-03-23 11:36 ` [PATCH 5/8] netfilter: bridge: kill nf_bridge_pad Pablo Neira Ayuso
2015-03-23 11:36 ` [PATCH 6/8] netfilter: nft_rbtree: fix locking Pablo Neira Ayuso
2015-03-23 11:36 ` [PATCH 7/8] netfilter: nf_tables: reject NFT_SET_ELEM_INTERVAL_END flag for non-interval sets Pablo Neira Ayuso
2015-03-23 11:36 ` [PATCH 8/8] netfilter: ip6t_REJECT: check for IP6T_F_PROTO Pablo Neira Ayuso
2015-03-24  2:03 ` [PATCH 0/8] Netfilter updates for net-next David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427110584-5190-5-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).