LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

[patch 1/3] ipvs: only unlock in ip_vs_edit_service() if already locked

To: lvs-devel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx
Subject: [patch 1/3] ipvs: only unlock in ip_vs_edit_service() if already locked
Cc: Julius Volz <juliusv@xxxxxxxxxx>, Vince Busam <vbusam@xxxxxxxxxx>, Wensong Zhang <wensong@xxxxxxxxxxxx>, Julian Anastasov <ja@xxxxxx>, Sven Wegener <sven.wegener@xxxxxxxxxxx>
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Tue, 16 Sep 2008 17:13:19 +1000
Jumping to out unlocks __ip_vs_svc_lock, but that lock is not taken until
after code that may jump to out.

This problem was detected by sparse.

make C=1
  CHECK   net/ipv4/ipvs/ip_vs_ctl.c
net/ipv4/ipvs/ip_vs_ctl.c:1332:2: warning: context imbalance in 
'ip_vs_edit_service' - unexpected unlock

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

Index: lvs-2.6/net/ipv4/ipvs/ip_vs_ctl.c
===================================================================
--- lvs-2.6.orig/net/ipv4/ipvs/ip_vs_ctl.c      2008-09-16 15:16:01.000000000 
+1000
+++ lvs-2.6/net/ipv4/ipvs/ip_vs_ctl.c   2008-09-16 15:16:06.000000000 +1000
@@ -1305,7 +1305,7 @@ ip_vs_edit_service(struct ip_vs_service 
                 */
                if ((ret = ip_vs_unbind_scheduler(svc))) {
                        old_sched = sched;
-                       goto out;
+                       goto out_unlock;
                }
 
                /*
@@ -1324,12 +1324,13 @@ ip_vs_edit_service(struct ip_vs_service 
                         */
                        ip_vs_bind_scheduler(svc, old_sched);
                        old_sched = sched;
-                       goto out;
+                       goto out_unlock;
                }
        }
 
-  out:
+  out_unlock:
        write_unlock_bh(&__ip_vs_svc_lock);
+  out:
 
        if (old_sched)
                ip_vs_scheduler_put(old_sched);

-- 

-- 
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en

--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

<Prev in Thread] Current Thread [Next in Thread>