Skip to content

Commit

Permalink
XFRM: Fix memory leak in xfrm_state_update
Browse files Browse the repository at this point in the history
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>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tushar Gohad authored and David S. Miller committed Jul 8, 2011
1 parent f8d9605 commit 8fcbc63
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,8 @@ int xfrm_state_update(struct xfrm_state *x)
xfrm_state_check_expire(x1);

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

Expand Down

0 comments on commit 8fcbc63

Please sign in to comment.