Patchwork [1/3] ipv6: ip6_route_output() never returns NULL.

login
register
mail settings
Submitter roy.qing.li@gmail.com
Date Feb. 22, 2012, 8:10 a.m.
Message ID <1329898251-5357-1-git-send-email-roy.qing.li@gmail.com>
Download mbox | patch
Permalink /patch/142413/
State Accepted
Delegated to: David Miller
Headers show

Comments

roy.qing.li@gmail.com - Feb. 22, 2012, 8:10 a.m.
From: RongQing.Li <roy.qing.li@gmail.com> 

ip6_route_output() never returns NULL, so it is wrong to
check if the return value is NULL.

Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
---
 net/ipv6/ip6mr.c |    4 +++-
 net/ipv6/ndisc.c |    5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
David Miller - Feb. 22, 2012, 7:50 p.m.
From: roy.qing.li@gmail.com
Date: Wed, 22 Feb 2012 16:10:49 +0800

> From: RongQing.Li <roy.qing.li@gmail.com> 
> 
> ip6_route_output() never returns NULL, so it is wrong to
> check if the return value is NULL.
> 
> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index c7e95c8..5aa3981 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1926,8 +1926,10 @@  static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
 	};
 
 	dst = ip6_route_output(net, NULL, &fl6);
-	if (!dst)
+	if (dst->error) {
+		dst_release(dst);
 		goto out_free;
+	}
 
 	skb_dst_drop(skb);
 	skb_dst_set(skb, dst);
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 8d81701..3dcdb81 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1550,9 +1550,10 @@  void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 			 &saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex);
 
 	dst = ip6_route_output(net, NULL, &fl6);
-	if (dst == NULL)
+	if (dst->error) {
+		dst_release(dst);
 		return;
-
+	}
 	dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
 	if (IS_ERR(dst))
 		return;