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.
Unified · Split
| @@ -1658,7 +1658,6 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, · 1657 unmodified lines | ||
| 1658 | 1658 | trailer_len -= xdst_prev->u.dst.xfrm->props.trailer_len; |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | −out: | |
| 1662 | 1661 | return &xdst0->u.dst; |
| 1663 | 1662 | |
| 1664 | 1663 | put_states: |
| @@ -1667,8 +1666,8 @@ put_states: · 2 unmodified lines | ||
| 1667 | 1666 | free_dst: |
| 1668 | 1667 | if (xdst0) |
| 1669 | 1668 | dst_release_immediate(&xdst0->u.dst); |
| 1670 | − xdst0 = ERR_PTR(err); | |
| 1671 | − goto out; | |
| 1669 | + | |
| 1670 | + return ERR_PTR(err); | |
| 1672 | 1671 | } |
| 1673 | 1672 | |
| 1674 | 1673 | static int xfrm_expand_policies(const struct flowi *fl, u16 family, |