Patchwork xfrm: Fix xfrm_state_migrate leak

login
register
mail settings
Submitter Steffen Klassert
Date Dec. 7, 2010, 9:28 a.m.
Message ID <20101207092856.GL4639@secunet.com>
Download mbox | patch
Permalink /patch/74495/
State Accepted
Delegated to: David Miller
Headers show

Comments

Steffen Klassert - Dec. 7, 2010, 9:28 a.m.
From: Thomas Egerer <thomas.egerer@secunet.com>

xfrm_state_migrate calls kfree instead of xfrm_state_put to free
a failed state. According to git commit 553f9118 this can cause
memory leaks.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/xfrm/xfrm_state.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Herbert Xu - Dec. 7, 2010, 9:31 a.m.
On Tue, Dec 07, 2010 at 10:28:56AM +0100, Steffen Klassert wrote:
> From: Thomas Egerer <thomas.egerer@secunet.com>
> 
> xfrm_state_migrate calls kfree instead of xfrm_state_put to free
> a failed state. According to git commit 553f9118 this can cause
> memory leaks.
> 
> Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

Acked-by: Herbert Xu <herbert@gondor.apana.org.au>

Good catch.  Thanks!
David Miller - Dec. 10, 2010, 4:36 a.m.
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Tue, 7 Dec 2010 17:31:57 +0800

> On Tue, Dec 07, 2010 at 10:28:56AM +0100, Steffen Klassert wrote:
>> From: Thomas Egerer <thomas.egerer@secunet.com>
>> 
>> xfrm_state_migrate calls kfree instead of xfrm_state_put to free
>> a failed state. According to git commit 553f9118 this can cause
>> memory leaks.
>> 
>> Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
>> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> 
> Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
> 
> Good catch.  Thanks!

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

Patch

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index eb96ce5..220ebc0 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1268,7 +1268,7 @@  struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x,
 
 	return xc;
 error:
-	kfree(xc);
+	xfrm_state_put(xc);
 	return NULL;
 }
 EXPORT_SYMBOL(xfrm_state_migrate);