From: Steffen Klassert Date: Wed, 18 Jun 2014 10:34:21 +0000 (+0200) Subject: xfrm: Fix refcount imbalance in xfrm_lookup X-Git-Tag: v3.15.10~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4b76e18681b8574f61bdf95981270c94ae82938;p=thirdparty%2Fkernel%2Fstable.git xfrm: Fix refcount imbalance in xfrm_lookup [ Upstream commit b7eea4545ea775df957460f58eb56085a8892856 ] xfrm_lookup must return a dst_entry with a refcount for the caller. Git commit 1a1ccc96abb ("xfrm: Remove caching of xfrm_policy_sk_bundles") removed this refcount for the socket policy case accidentally. This patch restores it and sets DST_NOCACHE flag to make sure that the dst_entry is freed when the refcount becomes null. Fixes: 1a1ccc96abb ("xfrm: Remove caching of xfrm_policy_sk_bundles") Signed-off-by: Steffen Klassert Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index c08fbd11ceff5..ed608432e4f96 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -2107,6 +2107,8 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, goto no_transform; } + dst_hold(&xdst->u.dst); + xdst->u.dst.flags |= DST_NOCACHE; route = xdst->route; } }