Skip to contentSkip to conversation

net: fix memory leak on oom with zerocopy

PATCH Applied Michael S. Tsirkin 2 participants 2 messages Sep 16, 2012 – Sep 18, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: fix memory leak on oom with zerocopy

If orphan flags fails, we don't free the skb
on receive, which leaks the skb memory.

Return value was also wrong: netif_receive_skb
is supposed to return NET_RX_DROP, not ENOMEM.

---

Fixes a memory leak so 3.6 material?

 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index 8398836..899f827 100644
@@ -3321,7 +3321,7 @@ ncls:
 
 	if (pt_prev) {
 		if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
-			ret = -ENOMEM;
+			goto drop;
 		else
 			ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
 	} else {
Signature · 1 line
MST
maintainer Applied
#1 lore raw

From: "Michael S. Tsirkin" <[email protected]>
Date: Sun, 16 Sep 2012 11:44:16 +0300

Quoted 7 lines

If orphan flags fails, we don't free the skb
on receive, which leaks the skb memory.

Return value was also wrong: netif_receive_skb
is supposed to return NET_RX_DROP, not ENOMEM.

Applied, thanks Michael.