Skip to contentSkip to conversation

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

PATCH In review CAI Qian 2 participants 2 messages Dec 7, 2012 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

CAI Qian

author
#1 lore raw

PATCH 1/1 ipv4: avoid passing NULL to inet_putpeer() in icmpv4_xrlim_allow()

David, this patch looks applicable for the stable releases.

Quoted 1 line

From Neal Cardwell <[email protected]>

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.").

Upstream-ID: e1a676424c290b1c8d757e3860170ac7ecd89af4
Stable-trees: 3.6.x

net/ipv4/icmp.c +2 -1
index f2eccd5..17ff9fd 100644
@@ -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;
maintainer
#2 lore raw

From: CAI Qian <[email protected]>
Date: Fri, 7 Dec 2012 10:46:40 -0500 (EST)

Quoted 12 lines

David, this patch looks applicable for the stable releases.

From Neal Cardwell <[email protected]>

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.").

Quoted 6 lines

Upstream-ID: e1a676424c290b1c8d757e3860170ac7ecd89af4
Stable-trees: 3.6.x

Please stop submitting networking -stable changes.