From: Michael S. Tsirkin <mst@redhat.com>
Date: Sat, 15 Sep 2012 22:44:16 +0000 (+0000)
Subject: net: fix memory leak on oom with zerocopy
X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=0e698bf6624c469cd4f3f391247b142963ca9c4e;p=openwrt%2Fstaging%2Fblogic.git

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---

diff --git a/net/core/dev.c b/net/core/dev.c
index d7fe32c946c1..ac7609d85187 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3322,7 +3322,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 {