Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1a67642 authored by Neal Cardwell's avatar Neal Cardwell Committed by David S. Miller
Browse files

ipv4: avoid passing NULL to inet_putpeer() in icmpv4_xrlim_allow()



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:
1d861aa4 ("inet: Minimize use of
cached route inetpeer.").

Signed-off-by: default avatarNeal Cardwell <ncardwell@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 81b40110
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -257,6 +257,7 @@ 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);
		if (peer)
			inet_putpeer(peer);
	}
out: