]> git.hungrycats.org Git - linux/commitdiff
xfrm: Refcount destination entry on xfrm_lookup
authorSteffen Klassert <steffen.klassert@secunet.com>
Tue, 15 Mar 2011 21:12:49 +0000 (21:12 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 21 Apr 2011 21:32:34 +0000 (14:32 -0700)
[ Upstream commit fbd5060875d25f7764fd1c3d35b83a8ed1d88d7b ]

We return a destination entry without refcount if a socket
policy is found in xfrm_lookup. This triggers a warning on
a negative refcount when freeeing this dst entry. So take
a refcount in this case to fix it.

This refcount was forgotten when xfrm changed to cache bundles
instead of policies for outgoing flows.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Acked-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/xfrm/xfrm_policy.c

index 6459588befc33fc58baa4f341b04f95e7a675bca..8da2741d7997b18fa6a701b201d9fbbbc98581f3 100644 (file)
@@ -1778,6 +1778,8 @@ restart:
                                goto no_transform;
                        }
 
+                       dst_hold(&xdst->u.dst);
+
                        spin_lock_bh(&xfrm_policy_sk_bundle_lock);
                        xdst->u.dst.next = xfrm_policy_sk_bundles;
                        xfrm_policy_sk_bundles = &xdst->u.dst;