summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-06-11 15:52:29 -0700
committerDavid S. Miller <davem@davemloft.net>2012-06-11 15:52:29 -0700
commit55afabaa0df0dd139c8796a71beb43d1216fbe43 (patch)
tree5f3ad3d76d9101c11d15197b40fb4f86402db3a9
parent352e04b9111d608bd89ba7bd8070846d4f97d104 (diff)
downloadlinux-55afabaa0df0dd139c8796a71beb43d1216fbe43.tar.gz
linux-55afabaa0df0dd139c8796a71beb43d1216fbe43.tar.bz2
linux-55afabaa0df0dd139c8796a71beb43d1216fbe43.zip
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: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/ip6_route.h2
-rw-r--r--include/net/route.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index f88a85cf31c3..a2cda240ca95 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -61,7 +61,7 @@ static inline struct inet_peer *__rt6_get_peer(struct rt6_info *rt, int create)
return rt6_peer_ptr(rt);
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)
diff --git a/include/net/route.h b/include/net/route.h
index cc693a5bb20d..2bfbc9329ea9 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -334,7 +334,7 @@ static inline struct inet_peer *__rt_get_peer(struct rtable *rt, __be32 daddr, i
return rt_peer_ptr(rt);
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)