Skip to contentSkip to conversation

neigh: check error pointer instead of NULL for ipv4_neigh_lookup()

PATCH Applied Cong Wang 3 participants 4 messages Sep 25, 2014 – Sep 28, 2014

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 neigh: check error pointer instead of NULL for ipv4_neigh_lookup()

Fixes commit f187bc6efb7250afee0e2009b6106 ("ipv4: No need to set generic neighbour pointer")
Cc David S. Miller <[email protected]>
---
 net/ipv4/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +1 -1
index 173e7ea..cbadb94 100644
@@ -746,7 +746,7 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow
 	}
 
 	n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw);
-	if (n) {
+	if (!IS_ERR(n)) {
 		if (!(n->nud_state & NUD_VALID)) {
 			neigh_event_send(n, NULL);
 		} else {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 12 lines · Cong Wang
Fixes commit f187bc6efb7250afee0e2009b6106 ("ipv4: No need to set generic neighbour pointer")
Cc David S. Miller <[email protected]>
---
 net/ipv4/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +0 -0
index 173e7ea..cbadb94 100644

net/ipv4/route.c static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow · line 751

Quoted 7 lines
net/ipv4/route.c +1 -1
@@ -746,7 +746,7 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow
        }
 
        n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw);
-       if (n) {
+       if (!IS_ERR(n)) {
                if (!(n->nud_state & NUD_VALID)) {
                        neigh_event_send(n, NULL);

assuming symptoms of this was a crash?
Could you share the stack trace to see how we got to this state ? Or was it spotted just by code inspection?

Thanks!

author
#2 lore raw
Quoted 1 line · Alexei Starovoitov

assuming symptoms of this was a crash?

No.

Quoted 1 line

Or was it spotted just by code inspection?

Yes.