Skip to content

Commit

Permalink
ipv4: avoid passing NULL to inet_putpeer() in icmpv4_xrlim_allow()
Browse files Browse the repository at this point in the history
inet_getpeer_v4() can return NULL under OOM conditions, and while
inet_peer_xrlim_allow() is OK with a NULL peer, inet_putpeer() will
crash.

This code path now uses the same idiom as the others from:
1d861aa ("inet: Minimize use of
cached route inetpeer.").

Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
nealcardwell authored and davem330 committed Nov 26, 2012
1 parent 81b4011 commit e1a6764
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ static inline bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt,
struct inet_peer *peer = inet_getpeer_v4(net->ipv4.peers, fl4->daddr, 1);
rc = inet_peer_xrlim_allow(peer,
net->ipv4.sysctl_icmp_ratelimit);
inet_putpeer(peer);
if (peer)
inet_putpeer(peer);
}
out:
return rc;
Expand Down

0 comments on commit e1a6764

Please sign in to comment.