Skip to content

Commit

Permalink
xfrm Fix potential error pointer dereference in xfrm_bundle_create.
Browse files Browse the repository at this point in the history
We may derference an invalid pointer in the error path of
xfrm_bundle_create(). Fix this by returning this error
pointer directly instead of assigning it to xdst0.

Fixes: 45b018b ("ipsec: Create and use new helpers for dst child access.")
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
klassert committed May 31, 2018
1 parent d9f9277 commit 38369f5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions net/xfrm/xfrm_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,6 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
trailer_len -= xdst_prev->u.dst.xfrm->props.trailer_len;
}

out:
return &xdst0->u.dst;

put_states:
Expand All @@ -1667,8 +1666,8 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
free_dst:
if (xdst0)
dst_release_immediate(&xdst0->u.dst);
xdst0 = ERR_PTR(err);
goto out;

return ERR_PTR(err);
}

static int xfrm_expand_policies(const struct flowi *fl, u16 family,
Expand Down

0 comments on commit 38369f5

Please sign in to comment.