From patchwork Thu Jan 31 00:04:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [nftables,4/9] netfilter: nf_tables: fix error path in newchain Date: Wed, 30 Jan 2013 14:04:00 -0000 From: Pablo Neira X-Patchwork-Id: 217052 Message-Id: <1359590645-4703-4-git-send-email-pablo@netfilter.org> To: netfilter-devel@vger.kernel.org Cc: kaber@trash.net, tomasz.bursztyka@linux.intel.com From: Pablo Neira Ayuso Make sure the chain is not in the table list until the hook registration returns success. Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_tables_api.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 7f08381..031aad9 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -868,8 +868,6 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb, chain->net = net; nla_strlcpy(chain->name, name, NFT_CHAIN_MAXNAMELEN); - list_add_tail(&chain->list, &table->chains); - if (!(table->flags & NFT_TABLE_F_DORMANT) && chain->flags & NFT_BASE_CHAIN) { err = nf_register_hook(&nft_base_chain(chain)->ops); @@ -878,6 +876,7 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb, return err; } } + list_add_tail(&chain->list, &table->chains); notify: nf_tables_chain_notify(skb, nlh, table, chain, NFT_MSG_NEWCHAIN, family);