ChangeSet 1.2331, 2005/03/31 22:24:38-08:00, [EMAIL PROTECTED]

        [XFRM]: Simplify xfrm_policy_kill().
        
        So here is a patch to simplify xfrm_policy_kill() by moving the
        GC linking after the write_unlock_bh().
        
        Actually, as the code stands, xfrm_policy_kill() should/will never
        be called twice on the same policy.  So we can add a warning to
        catch that.
        
        Signed-off-by: Herbert Xu <[EMAIL PROTECTED]>
        Signed-off-by: David S. Miller <[EMAIL PROTECTED]>



 xfrm_policy.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)


diff -Nru a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
--- a/net/xfrm/xfrm_policy.c    2005-04-01 09:10:42 -08:00
+++ b/net/xfrm/xfrm_policy.c    2005-04-01 09:10:42 -08:00
@@ -13,6 +13,7 @@
  *     
  */
 
+#include <asm/bug.h>
 #include <linux/config.h>
 #include <linux/slab.h>
 #include <linux/kmod.h>
@@ -300,20 +301,20 @@
 
 static void xfrm_policy_kill(struct xfrm_policy *policy)
 {
+       int dead;
+
        write_lock_bh(&policy->lock);
-       if (policy->dead) {
-               write_unlock_bh(&policy->lock);
+       dead = policy->dead;
+       policy->dead = 1;
+       write_unlock_bh(&policy->lock);
+
+       if (unlikely(dead)) {
+               WARN_ON(1);
                return;
        }
-       policy->dead = 1;
 
        spin_lock(&xfrm_policy_gc_lock);
        list_add(&policy->list, &xfrm_policy_gc_list);
-       /*
-        * Unlock the policy (out of order unlocking), to make sure
-        * the GC context does not free it with an active lock:
-        */
-       write_unlock_bh(&policy->lock);
        spin_unlock(&xfrm_policy_gc_lock);
 
        schedule_work(&xfrm_policy_gc_work);
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to