inet: Avoid potential NULL peer dereference.
We handle NULL in rt{,6}_set_peer but then our caller will try to pass
that NULL pointer into inet_putpeer() which isn't ready for it.
Fix this by moving the NULL check one level up, and then remove the
now unnecessary NULL check from inetpeer_ptr_set_peer().
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index e15c086..c27c8f1 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -104,7 +104,7 @@
unsigned long val = (unsigned long) peer;
unsigned long orig = *ptr;
- if (!(orig & INETPEER_BASE_BIT) || !val ||
+ if (!(orig & INETPEER_BASE_BIT) ||
cmpxchg(ptr, orig, val) != orig)
return false;
return true;