]> err.no Git - linux-2.6/commitdiff
[IPV4]: Fix memory leak on error path during FIB initialization.
authorDenis V. Lunev <den@openvz.org>
Fri, 1 Feb 2008 02:44:53 +0000 (18:44 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Feb 2008 03:28:37 +0000 (19:28 -0800)
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>
net/ipv4/fib_frontend.c

index d28261826bc2b35b775946a378cef1959fa99077..d0507f4f848afe8729be29bc9df5e8affaa9fc2b 100644 (file)
@@ -975,6 +975,7 @@ static struct notifier_block fib_netdev_notifier = {
 
 static int __net_init ip_fib_net_init(struct net *net)
 {
+       int err;
        unsigned int i;
 
        net->ipv4.fib_table_hash = kzalloc(
@@ -985,7 +986,14 @@ static int __net_init ip_fib_net_init(struct net *net)
        for (i = 0; i < FIB_TABLE_HASHSZ; i++)
                INIT_HLIST_HEAD(&net->ipv4.fib_table_hash[i]);
 
-       return fib4_rules_init(net);
+       err = fib4_rules_init(net);
+       if (err < 0)
+               goto fail;
+       return 0;
+
+fail:
+       kfree(net->ipv4.fib_table_hash);
+       return err;
 }
 
 static void __net_exit ip_fib_net_exit(struct net *net)