netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch] xfrm_policy_destroy: rename and relative fixes
@ 2008-01-03 12:05 WANG Cong
  2008-01-08  6:15 ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: WANG Cong @ 2008-01-03 12:05 UTC (permalink / raw)
  To: LKML; +Cc: Herbert Xu, David Miller, netdev


Since __xfrm_policy_destroy is used to destory the resources
allocated by xfrm_policy_alloc. So using the name
__xfrm_policy_destroy is not correspond with xfrm_policy_alloc.
Rename it to xfrm_policy_destroy.

And along with some instances that call xfrm_policy_alloc
but not using xfrm_policy_destroy to destroy the resource,
fix them.

Cc: David Miller <davem@davemloft.net>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>

---

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 58dfa82..6eff085 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -505,12 +505,12 @@ static inline void xfrm_pol_hold(struct xfrm_policy *policy)
 		atomic_inc(&policy->refcnt);
 }
 
-extern void __xfrm_policy_destroy(struct xfrm_policy *policy);
+extern void xfrm_policy_destroy(struct xfrm_policy *policy);
 
 static inline void xfrm_pol_put(struct xfrm_policy *policy)
 {
 	if (atomic_dec_and_test(&policy->refcnt))
-		__xfrm_policy_destroy(policy);
+		xfrm_policy_destroy(policy);
 }
 
 #ifdef CONFIG_XFRM_SUB_POLICY
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 26d5e63..3667f44 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2291,8 +2291,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
 	return 0;
 
 out:
-	security_xfrm_policy_free(xp);
-	kfree(xp);
+	xfrm_policy_destroy(xp);
 	return err;
 }
 
@@ -3236,8 +3235,7 @@ static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
 	return xp;
 
 out:
-	security_xfrm_policy_free(xp);
-	kfree(xp);
+	xfrm_policy_destroy(xp);
 	return NULL;
 }
 
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 26b846e..087484e 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -206,7 +206,7 @@ EXPORT_SYMBOL(xfrm_policy_alloc);
 
 /* Destroy xfrm_policy: descendant resources must be released to this moment. */
 
-void __xfrm_policy_destroy(struct xfrm_policy *policy)
+void xfrm_policy_destroy(struct xfrm_policy *policy)
 {
 	BUG_ON(!policy->dead);
 
@@ -218,7 +218,7 @@ void __xfrm_policy_destroy(struct xfrm_policy *policy)
 	security_xfrm_policy_free(policy);
 	kfree(policy);
 }
-EXPORT_SYMBOL(__xfrm_policy_destroy);
+EXPORT_SYMBOL(xfrm_policy_destroy);
 
 static void xfrm_policy_gc_kill(struct xfrm_policy *policy)
 {
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index e75dbdc..73cc755 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1048,7 +1048,7 @@ static struct xfrm_policy *xfrm_policy_construct(struct xfrm_userpolicy_info *p,
 	return xp;
  error:
 	*errp = err;
-	kfree(xp);
+	xfrm_policy_destroy(xp);
 	return NULL;
 }
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch] xfrm_policy_destroy: rename and relative fixes
  2008-01-03 12:05 [Patch] xfrm_policy_destroy: rename and relative fixes WANG Cong
@ 2008-01-08  6:15 ` Herbert Xu
  2008-01-08  6:34   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2008-01-08  6:15 UTC (permalink / raw)
  To: WANG Cong; +Cc: LKML, David Miller, netdev

On Thu, Jan 03, 2008 at 08:05:50PM +0800, WANG Cong wrote:
> 
> Since __xfrm_policy_destroy is used to destory the resources
> allocated by xfrm_policy_alloc. So using the name
> __xfrm_policy_destroy is not correspond with xfrm_policy_alloc.
> Rename it to xfrm_policy_destroy.
> 
> And along with some instances that call xfrm_policy_alloc
> but not using xfrm_policy_destroy to destroy the resource,
> fix them.
> 
> Cc: David Miller <davem@davemloft.net>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>

This patch looks OK to me.

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch] xfrm_policy_destroy: rename and relative fixes
  2008-01-08  6:15 ` Herbert Xu
@ 2008-01-08  6:34   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2008-01-08  6:34 UTC (permalink / raw)
  To: herbert; +Cc: xiyou.wangcong, linux-kernel, netdev

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Tue, 8 Jan 2008 17:15:16 +1100

> On Thu, Jan 03, 2008 at 08:05:50PM +0800, WANG Cong wrote:
> > 
> > Since __xfrm_policy_destroy is used to destory the resources
> > allocated by xfrm_policy_alloc. So using the name
> > __xfrm_policy_destroy is not correspond with xfrm_policy_alloc.
> > Rename it to xfrm_policy_destroy.
> > 
> > And along with some instances that call xfrm_policy_alloc
> > but not using xfrm_policy_destroy to destroy the resource,
> > fix them.
> > 
> > Cc: David Miller <davem@davemloft.net>
> > Cc: Herbert Xu <herbert@gondor.apana.org.au>
> > Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
> 
> This patch looks OK to me.

Applied, thanks everyone.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-08  6:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-03 12:05 [Patch] xfrm_policy_destroy: rename and relative fixes WANG Cong
2008-01-08  6:15 ` Herbert Xu
2008-01-08  6:34   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).