diff options
author | Denis V. Lunev <den@openvz.org> | 2008-01-31 21:44:53 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-31 22:28:37 -0500 |
commit | dce5cbeec32eb5db4d406b732b1256c6f702bde5 (patch) | |
tree | 38c9fe8ba24567d7914b949059a896f683aa6e29 /net/ipv4/fib_frontend.c | |
parent | 3ed5df445eddce6f37767df3ebe8b27b614c7d98 (diff) |
[IPV4]: Fix memory leak on error path during FIB initialization.
net->ipv4.fib_table_hash is not freed when fib4_rules_init failed.
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.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index d28261826bc2..d0507f4f848a 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -975,6 +975,7 @@ static struct notifier_block fib_netdev_notifier = { | |||
975 | 975 | ||
976 | static int __net_init ip_fib_net_init(struct net *net) | 976 | static int __net_init ip_fib_net_init(struct net *net) |
977 | { | 977 | { |
978 | int err; | ||
978 | unsigned int i; | 979 | unsigned int i; |
979 | 980 | ||
980 | net->ipv4.fib_table_hash = kzalloc( | 981 | net->ipv4.fib_table_hash = kzalloc( |
@@ -985,7 +986,14 @@ static int __net_init ip_fib_net_init(struct net *net) | |||
985 | for (i = 0; i < FIB_TABLE_HASHSZ; i++) | 986 | for (i = 0; i < FIB_TABLE_HASHSZ; i++) |
986 | INIT_HLIST_HEAD(&net->ipv4.fib_table_hash[i]); | 987 | INIT_HLIST_HEAD(&net->ipv4.fib_table_hash[i]); |
987 | 988 | ||
988 | return fib4_rules_init(net); | 989 | err = fib4_rules_init(net); |
990 | if (err < 0) | ||
991 | goto fail; | ||
992 | return 0; | ||
993 | |||
994 | fail: | ||
995 | kfree(net->ipv4.fib_table_hash); | ||
996 | return err; | ||
989 | } | 997 | } |
990 | 998 | ||
991 | static void __net_exit ip_fib_net_exit(struct net *net) | 999 | static void __net_exit ip_fib_net_exit(struct net *net) |