Skip to contentSkip to conversation

Make sure error handling is done when calling ip6_route_output().

PATCH Applied Ville Nuorvala 2 participants 2 messages Oct 17, 2006

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

PATCH 3/13 Make sure error handling is done when calling ip6_route_output().

As ip6_route_output() never returns NULL, error checking must be done by looking at dst->error in stead of comparing dst against NULL.

---
 net/ipv6/xfrm6_policy.c |   12 +++++++-----
 net/sctp/ipv6.c         |   10 +++++-----
 2 files changed, 12 insertions(+), 10 deletions(-)
net/ipv6/xfrm6_policy.c +7 -5
index 6a252e2..db2d55c 100644
@@ -25,12 +25,14 @@ #endif
 static struct dst_ops xfrm6_dst_ops;
 static struct xfrm_policy_afinfo xfrm6_policy_afinfo;
 
-static int xfrm6_dst_lookup(struct xfrm_dst **dst, struct flowi *fl)
+static int xfrm6_dst_lookup(struct xfrm_dst **xdst, struct flowi *fl)
 {
-	int err = 0;
-	*dst = (struct xfrm_dst*)ip6_route_output(NULL, fl);
-	if (!*dst)
-		err = -ENETUNREACH;
+	struct dst_entry *dst = ip6_route_output(NULL, fl);
+	int err = dst->error;
+	if (!err)
+		*xdst = (struct xfrm_dst *) dst;
+	else
+		dst_release(dst);
 	return err;
 }
 
net/sctp/ipv6.c +5 -5
index 249e503..78071c6 100644
@@ -215,17 +215,17 @@ static struct dst_entry *sctp_v6_get_dst
 	}
 
 	dst = ip6_route_output(NULL, &fl);
-	if (dst) {
+	if (!dst->error) {
 		struct rt6_info *rt;
 		rt = (struct rt6_info *)dst;
 		SCTP_DEBUG_PRINTK(
 			"rt6_dst:" NIP6_FMT " rt6_src:" NIP6_FMT "\n",
 			NIP6(rt->rt6i_dst.addr), NIP6(rt->rt6i_src.addr));
-	} else {
-		SCTP_DEBUG_PRINTK("NO ROUTE\n");
+		return dst;
 	}
-
-	return dst;
+	SCTP_DEBUG_PRINTK("NO ROUTE\n");
+	dst_release(dst);
+	return NULL;
 }
 
 /* Returns the number of consecutive initial bits that match in the 2 ipv6
Signature · 1 line
1.4.2.3
maintainer
#1 lore raw

From: Ville Nuorvala <[email protected]>
Date: Tue, 17 Oct 2006 03:04:08 +0300

Quoted 4 lines

As ip6_route_output() never returns NULL, error checking must be done by looking at dst->error in stead of comparing dst against NULL.

Good catch, patch applied.

Thanks a lot.