aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2005-03-31 06:24:38 -0800
committerDavid S. Miller <davem@sunset.davemloft.net>2005-03-31 06:24:38 -0800
commit1f2ad0e4a5499c03409dda5980a7c1bc48ac6aaa (patch)
treee26c5055a43781519090744dda3ca8beaf35718b
parent384b4336e40d686e7a617adc1af032f2915f9733 (diff)
downloadhistory-1f2ad0e4a5499c03409dda5980a7c1bc48ac6aaa.tar.gz
[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 <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/xfrm/xfrm_policy.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index fbf8270619255c..80828078733dd9 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -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_gc_task(void *data)
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);