Commit 23d07508 authored by Gao Feng's avatar Gao Feng Committed by Pablo Neira Ayuso

netfilter: Add the missed return value check of nft_register_chain_type

There are some codes of netfilter module which did not check the return
value of nft_register_chain_type. Add the checks now.
Signed-off-by: default avatarGao Feng <fgao@ikuai8.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 4e6577de
...@@ -139,12 +139,20 @@ static int __init nf_tables_bridge_init(void) ...@@ -139,12 +139,20 @@ static int __init nf_tables_bridge_init(void)
int ret; int ret;
nf_register_afinfo(&nf_br_afinfo); nf_register_afinfo(&nf_br_afinfo);
nft_register_chain_type(&filter_bridge); ret = nft_register_chain_type(&filter_bridge);
if (ret < 0)
goto err1;
ret = register_pernet_subsys(&nf_tables_bridge_net_ops); ret = register_pernet_subsys(&nf_tables_bridge_net_ops);
if (ret < 0) { if (ret < 0)
goto err2;
return ret;
err2:
nft_unregister_chain_type(&filter_bridge); nft_unregister_chain_type(&filter_bridge);
err1:
nf_unregister_afinfo(&nf_br_afinfo); nf_unregister_afinfo(&nf_br_afinfo);
}
return ret; return ret;
} }
......
...@@ -80,7 +80,10 @@ static int __init nf_tables_arp_init(void) ...@@ -80,7 +80,10 @@ static int __init nf_tables_arp_init(void)
{ {
int ret; int ret;
nft_register_chain_type(&filter_arp); ret = nft_register_chain_type(&filter_arp);
if (ret < 0)
return ret;
ret = register_pernet_subsys(&nf_tables_arp_net_ops); ret = register_pernet_subsys(&nf_tables_arp_net_ops);
if (ret < 0) if (ret < 0)
nft_unregister_chain_type(&filter_arp); nft_unregister_chain_type(&filter_arp);
......
...@@ -103,7 +103,10 @@ static int __init nf_tables_ipv4_init(void) ...@@ -103,7 +103,10 @@ static int __init nf_tables_ipv4_init(void)
{ {
int ret; int ret;
nft_register_chain_type(&filter_ipv4); ret = nft_register_chain_type(&filter_ipv4);
if (ret < 0)
return ret;
ret = register_pernet_subsys(&nf_tables_ipv4_net_ops); ret = register_pernet_subsys(&nf_tables_ipv4_net_ops);
if (ret < 0) if (ret < 0)
nft_unregister_chain_type(&filter_ipv4); nft_unregister_chain_type(&filter_ipv4);
......
...@@ -100,7 +100,10 @@ static int __init nf_tables_ipv6_init(void) ...@@ -100,7 +100,10 @@ static int __init nf_tables_ipv6_init(void)
{ {
int ret; int ret;
nft_register_chain_type(&filter_ipv6); ret = nft_register_chain_type(&filter_ipv6);
if (ret < 0)
return ret;
ret = register_pernet_subsys(&nf_tables_ipv6_net_ops); ret = register_pernet_subsys(&nf_tables_ipv6_net_ops);
if (ret < 0) if (ret < 0)
nft_unregister_chain_type(&filter_ipv6); nft_unregister_chain_type(&filter_ipv6);
......
...@@ -82,7 +82,10 @@ static int __init nf_tables_inet_init(void) ...@@ -82,7 +82,10 @@ static int __init nf_tables_inet_init(void)
{ {
int ret; int ret;
nft_register_chain_type(&filter_inet); ret = nft_register_chain_type(&filter_inet);
if (ret < 0)
return ret;
ret = register_pernet_subsys(&nf_tables_inet_net_ops); ret = register_pernet_subsys(&nf_tables_inet_net_ops);
if (ret < 0) if (ret < 0)
nft_unregister_chain_type(&filter_inet); nft_unregister_chain_type(&filter_inet);
......
...@@ -149,7 +149,10 @@ static int __init nf_tables_netdev_init(void) ...@@ -149,7 +149,10 @@ static int __init nf_tables_netdev_init(void)
{ {
int ret; int ret;
nft_register_chain_type(&nft_filter_chain_netdev); ret = nft_register_chain_type(&nft_filter_chain_netdev);
if (ret)
return ret;
ret = register_pernet_subsys(&nf_tables_netdev_net_ops); ret = register_pernet_subsys(&nf_tables_netdev_net_ops);
if (ret) if (ret)
goto err1; goto err1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment