]> err.no Git - linux-2.6/commitdiff
[IPVS]: Don't leak sysctl tables if the scheduler registration fails.
authorPavel Emelyanov <xemul@openvz.org>
Tue, 4 Dec 2007 08:43:24 +0000 (00:43 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 5 Dec 2007 13:37:26 +0000 (05:37 -0800)
In case we load lblc or lblcr module we can leak some sysctl
tables if the call to register_ip_vs_scheduler() fails.

I've looked at the register_ip_vs_scheduler() code and saw, that
the only reason to fail is the name collision, so I think that
with some 3rd party schedulers this becomes a relevant issue. No?

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ipvs/ip_vs_lblc.c
net/ipv4/ipvs/ip_vs_lblcr.c

index b843a11d7cf7c33ae187a8879841516e33927e31..ad89644ef5d27e797f9a188451dc4f5c315cce70 100644 (file)
@@ -580,9 +580,14 @@ static struct ip_vs_scheduler ip_vs_lblc_scheduler =
 
 static int __init ip_vs_lblc_init(void)
 {
+       int ret;
+
        INIT_LIST_HEAD(&ip_vs_lblc_scheduler.n_list);
        sysctl_header = register_sysctl_table(lblc_root_table);
-       return register_ip_vs_scheduler(&ip_vs_lblc_scheduler);
+       ret = register_ip_vs_scheduler(&ip_vs_lblc_scheduler);
+       if (ret)
+               unregister_sysctl_table(sysctl_header);
+       return ret;
 }
 
 
index e5b323a6b2f784a02389f5cdc4e4fceedd508be9..2a5ed85a3352f6a7ad06658c478cf29d7065d62a 100644 (file)
@@ -769,9 +769,14 @@ static struct ip_vs_scheduler ip_vs_lblcr_scheduler =
 
 static int __init ip_vs_lblcr_init(void)
 {
+       int ret;
+
        INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list);
        sysctl_header = register_sysctl_table(lblcr_root_table);
-       return register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
+       ret = register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
+       if (ret)
+               unregister_sysctl_table(sysctl_header);
+       return ret;
 }