]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
IPSEC: Fix potential dst leak in xfrm_lookup
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 20 Dec 2007 00:35:54 +0000 (16:35 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 8 Feb 2008 20:01:14 +0000 (12:01 -0800)
[IPSEC]: Fix potential dst leak in xfrm_lookup

[ Upstream commit: 75b8c133267053c9986a7c8db5131f0e7349e806 ]

If we get an error during the actual policy lookup we don't free the
original dst while the caller expects us to always free the original
dst in case of error.

This patch fixes that.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/xfrm/xfrm_policy.c

index 7012891d39f2c6757b1c50784299043d353cc07a..75629f4b79146eb782a2bb566416a2a6ad548723 100644 (file)
@@ -1479,8 +1479,9 @@ restart:
 
        if (sk && sk->sk_policy[1]) {
                policy = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl);
+               err = PTR_ERR(policy);
                if (IS_ERR(policy))
-                       return PTR_ERR(policy);
+                       goto dropdst;
        }
 
        if (!policy) {
@@ -1491,8 +1492,9 @@ restart:
 
                policy = flow_cache_lookup(fl, dst_orig->ops->family,
                                           dir, xfrm_policy_lookup);
+               err = PTR_ERR(policy);
                if (IS_ERR(policy))
-                       return PTR_ERR(policy);
+                       goto dropdst;
        }
 
        if (!policy)
@@ -1661,8 +1663,9 @@ restart:
        return 0;
 
 error:
-       dst_release(dst_orig);
        xfrm_pols_put(pols, npols);
+dropdst:
+       dst_release(dst_orig);
        *dst_p = NULL;
        return err;
 }