Unverified Commit 06ed1b21 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!10458 xfrm6: check ip6_dst_idev() return value in xfrm6_get_saddr()

parents 79a2d839 f9733ad2
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -57,12 +57,18 @@ static int xfrm6_get_saddr(struct net *net, int oif,
{
{
	struct dst_entry *dst;
	struct dst_entry *dst;
	struct net_device *dev;
	struct net_device *dev;
	struct inet6_dev *idev;


	dst = xfrm6_dst_lookup(net, 0, oif, NULL, daddr, mark);
	dst = xfrm6_dst_lookup(net, 0, oif, NULL, daddr, mark);
	if (IS_ERR(dst))
	if (IS_ERR(dst))
		return -EHOSTUNREACH;
		return -EHOSTUNREACH;


	dev = ip6_dst_idev(dst)->dev;
	idev = ip6_dst_idev(dst);
	if (!idev) {
		dst_release(dst);
		return -EHOSTUNREACH;
	}
	dev = idev->dev;
	ipv6_dev_get_saddr(dev_net(dev), dev, &daddr->in6, 0, &saddr->in6);
	ipv6_dev_get_saddr(dev_net(dev), dev, &daddr->in6, 0, &saddr->in6);
	dst_release(dst);
	dst_release(dst);
	return 0;
	return 0;