xfrm: Fix xfrm_dst_cache memleak
authorSteffen Klassert <steffen.klassert@secunet.com>
Tue, 24 Oct 2017 08:28:43 +0000 (10:28 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Tue, 24 Oct 2017 11:40:36 +0000 (13:40 +0200)
We have a memleak whenever a flow matches a policy without
a matching SA. In this case we generate a dummy bundle and
take an additional refcount on the dst_entry. This was needed
as long as we had the flowcache. The flowcache removal patches
deleted all related refcounts but forgot the one for the
dummy bundle case. Fix the memleak by removing this refcount.

Fixes: 3ca28286ea80 ("xfrm_policy: bypass flow_cache_lookup")
Reported-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_policy.c

index 2746b62..8cafb3c 100644 (file)
@@ -2076,7 +2076,6 @@ make_dummy_bundle:
        xdst->num_xfrms = num_xfrms;
        memcpy(xdst->pols, pols, sizeof(struct xfrm_policy *) * num_pols);
 
-       dst_hold(&xdst->u.dst);
        return xdst;
 
 inc_error: