netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] XFRM: Fix memory leak in xfrm_state_update
@ 2011-07-08  1:38 Tushar Gohad
  2011-07-08  3:00 ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Tushar Gohad @ 2011-07-08  1:38 UTC (permalink / raw)
  To: David Miller, Herbert Xu; +Cc: netdev, tusharsg


Upon "ip xfrm state update ..", xfrm_add_sa() takes an extra reference on 
the user-supplied SA and forgets to drop the reference when 
xfrm_state_update() returns 0.  This leads to a memory leak as the 
parameter SA is never freed.  This change attempts to fix the leak by 
calling __xfrm_state_put() when xfrm_state_update() updates a valid SA 
(err = 0).  The parameter SA is added to the gc list when the final 
reference is dropped by xfrm_add_sa() upon completion.

Signed-off-by: Tushar Gohad <tgohad@mvista.com>
---
  net/xfrm/xfrm_state.c |    2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index d70f85e..9414b9c 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1345,6 +1345,8 @@ out:
  			xfrm_state_check_expire(x1);

  		err = 0;
+		x->km.state = XFRM_STATE_DEAD;
+		__xfrm_state_put(x);
  	}
  	spin_unlock_bh(&x1->lock);

-- 
1.6.3.3.202.g91879


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

end of thread, other threads:[~2011-07-08 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-08  1:38 [PATCH] XFRM: Fix memory leak in xfrm_state_update Tushar Gohad
2011-07-08  3:00 ` Herbert Xu
2011-07-08 15:59   ` 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).