Skip to content

Commit

Permalink
inet: Fix BUG triggered by __rt{,6}_get_peer().
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David S. Miller committed Jun 11, 2012
1 parent 352e04b commit 55afaba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/net/ip6_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion include/net/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 55afaba

Please sign in to comment.