diff options
author | David S. Miller <davem@davemloft.net> | 2012-06-11 04:13:57 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-11 04:13:57 -0700 |
commit | 7b34ca2ac7063f4ebf07f85fd75253ed84d5c648 (patch) | |
tree | 639e89875cd047bb461ab61348050586ceca56b2 /include/net/inetpeer.h | |
parent | 8b96d22d7a6ec999ae53ae86d829137503ceda65 (diff) |
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>
Diffstat (limited to 'include/net/inetpeer.h')
-rw-r--r-- | include/net/inetpeer.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h index e15c0862a68..c27c8f10ebd 100644 --- a/include/net/inetpeer.h +++ b/include/net/inetpeer.h @@ -104,7 +104,7 @@ static inline bool inetpeer_ptr_set_peer(unsigned long *ptr, struct inet_peer *p 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; |