Commit 55afabaa authored by David S. Miller's avatar David S. Miller

inet: Fix BUG triggered by __rt{,6}_get_peer().

If no peer actually gets attached (either because create is zero or
the peer allocation fails) we'll trigger a BUG because we
unconditionally do an rt{,6}_peer_ptr() afterwards.

Fix this by guarding it with the proper check.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 352e04b9
...@@ -61,7 +61,7 @@ static inline struct inet_peer *__rt6_get_peer(struct rt6_info *rt, int create) ...@@ -61,7 +61,7 @@ static inline struct inet_peer *__rt6_get_peer(struct rt6_info *rt, int create)
return rt6_peer_ptr(rt); return rt6_peer_ptr(rt);
rt6_bind_peer(rt, create); rt6_bind_peer(rt, create);
return rt6_peer_ptr(rt); return (rt6_has_peer(rt) ? rt6_peer_ptr(rt) : NULL);
} }
static inline struct inet_peer *rt6_get_peer(struct rt6_info *rt) static inline struct inet_peer *rt6_get_peer(struct rt6_info *rt)
......
...@@ -334,7 +334,7 @@ static inline struct inet_peer *__rt_get_peer(struct rtable *rt, __be32 daddr, i ...@@ -334,7 +334,7 @@ static inline struct inet_peer *__rt_get_peer(struct rtable *rt, __be32 daddr, i
return rt_peer_ptr(rt); return rt_peer_ptr(rt);
rt_bind_peer(rt, daddr, create); rt_bind_peer(rt, daddr, create);
return rt_peer_ptr(rt); return (rt_has_peer(rt) ? rt_peer_ptr(rt) : NULL);
} }
static inline struct inet_peer *rt_get_peer(struct rtable *rt, __be32 daddr) static inline struct inet_peer *rt_get_peer(struct rtable *rt, __be32 daddr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment