Skip to contentSkip to conversation

ipsec: Fix error handling in the function xfrm6_get_addr

PATCH New Bastien Philbert 1 participant 1 message Apr 5, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipsec: Fix error handling in the function xfrm6_get_addr

This fixes the error handling in the function xfrm_get_addr by checking if the call to ipv6_dev_get_saddr has failed and if so return -EADDRNOTAVAIL to signal to the caller of xfrm6_get_addr that the call has failed the error should be handled by the caller while also freeing the dst_entry structure pointer in use by this

---
 net/ipv6/xfrm6_policy.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv6/xfrm6_policy.c +4 -1
index c074771..759473e 100644
@@ -64,7 +64,10 @@ static int xfrm6_get_saddr(struct net *net, int oif,
 		return -EHOSTUNREACH;
 
 	dev = ip6_dst_idev(dst)->dev;
-	ipv6_dev_get_saddr(dev_net(dev), dev, &daddr->in6, 0, &saddr->in6);
+	if (ipv6_dev_get_saddr(dev_net(dev), dev, &daddr->in6, 0, &saddr->in6)) {
+		dst_release(dst);
+		return -EADDRNOTAVAIL;
+	}
 	dst_release(dst);
 	return 0;
 }
Signature · 1 line
2.5.0