netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipv4: avoid passing NULL to inet_putpeer() in icmpv4_xrlim_allow()
@ 2012-11-25  4:54 Neal Cardwell
  2012-11-26 22:25 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Neal Cardwell @ 2012-11-25  4:54 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Neal Cardwell

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

Signed-off-by: Neal Cardwell <ncardwell@google.com>
---
 net/ipv4/icmp.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index f2eccd5..17ff9fd 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -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;
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] ipv4: avoid passing NULL to inet_putpeer() in icmpv4_xrlim_allow()
  2012-11-25  4:54 [PATCH net] ipv4: avoid passing NULL to inet_putpeer() in icmpv4_xrlim_allow() Neal Cardwell
@ 2012-11-26 22:25 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-11-26 22:25 UTC (permalink / raw)
  To: ncardwell; +Cc: netdev

From: Neal Cardwell <ncardwell@google.com>
Date: Sat, 24 Nov 2012 23:54:37 -0500

> 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:
> 1d861aa4b3fb08822055345f480850205ffe6170 ("inet: Minimize use of
> cached route inetpeer.").
> 
> Signed-off-by: Neal Cardwell <ncardwell@google.com>

Applied, thanks a lot Neil.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-26 22:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-25  4:54 [PATCH net] ipv4: avoid passing NULL to inet_putpeer() in icmpv4_xrlim_allow() Neal Cardwell
2012-11-26 22:25 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).