aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_frontend.c
diff options
context:
space:
mode:
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);