aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_frontend.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-01-10 06:21:49 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:01:25 -0500
commitdbb50165b512f6c9b7aae10af73ae5b6d811f4d0 (patch)
tree9ba74fb468ec461668351a64c76c5f5d469842fa /net/ipv4/fib_frontend.c
parent61a0265344786a548e8a0b26cb668e78a71f9602 (diff)
[IPV4]: Check fib4_rules_init failure.
This adds error paths into both versions of fib4_rules_init (with/without CONFIG_IP_MULTIPLE_TABLES) and returns error code to the caller. Acked-by: Benjamin Thery <benjamin.thery@bull.net> Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_frontend.c')
-rw-r--r--net/ipv4/fib_frontend.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index ac6238a3b0fd..1bb956b3be28 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -59,12 +59,24 @@ struct fib_table *ip_fib_main_table;
59#define FIB_TABLE_HASHSZ 1 59#define FIB_TABLE_HASHSZ 1
60static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ]; 60static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ];
61 61
62static void __init fib4_rules_init(void) 62static int __init fib4_rules_init(void)
63{ 63{
64 ip_fib_local_table = fib_hash_init(RT_TABLE_LOCAL); 64 ip_fib_local_table = fib_hash_init(RT_TABLE_LOCAL);
65 hlist_add_head_rcu(&ip_fib_local_table->tb_hlist, &fib_table_hash[0]); 65 if (ip_fib_local_table == NULL)
66 return -ENOMEM;
67
66 ip_fib_main_table = fib_hash_init(RT_TABLE_MAIN); 68 ip_fib_main_table = fib_hash_init(RT_TABLE_MAIN);
69 if (ip_fib_main_table == NULL)
70 goto fail;
71
72 hlist_add_head_rcu(&ip_fib_local_table->tb_hlist, &fib_table_hash[0]);
67 hlist_add_head_rcu(&ip_fib_main_table->tb_hlist, &fib_table_hash[0]); 73 hlist_add_head_rcu(&ip_fib_main_table->tb_hlist, &fib_table_hash[0]);
74 return 0;
75
76fail:
77 kfree(ip_fib_local_table);
78 ip_fib_local_table = NULL;
79 return -ENOMEM;
68} 80}
69#else 81#else
70 82
@@ -944,7 +956,7 @@ void __init ip_fib_init(void)
944 for (i = 0; i < FIB_TABLE_HASHSZ; i++) 956 for (i = 0; i < FIB_TABLE_HASHSZ; i++)
945 INIT_HLIST_HEAD(&fib_table_hash[i]); 957 INIT_HLIST_HEAD(&fib_table_hash[i]);
946 958
947 fib4_rules_init(); 959 BUG_ON(fib4_rules_init());
948 960
949 register_netdevice_notifier(&fib_netdev_notifier); 961 register_netdevice_notifier(&fib_netdev_notifier);
950 register_inetaddr_notifier(&fib_inetaddr_notifier); 962 register_inetaddr_notifier(&fib_inetaddr_notifier);