From patchwork Sun Sep 16 08:44:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 184120 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D658A2C0087 for ; Sun, 16 Sep 2012 18:44:17 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751547Ab2IPImx (ORCPT ); Sun, 16 Sep 2012 04:42:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16086 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751228Ab2IPImv (ORCPT ); Sun, 16 Sep 2012 04:42:51 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8G8ghjt022488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 16 Sep 2012 04:42:43 -0400 Received: from redhat.com (vpn1-5-75.ams2.redhat.com [10.36.5.75]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id q8G8geCP023790; Sun, 16 Sep 2012 04:42:41 -0400 Date: Sun, 16 Sep 2012 11:44:16 +0300 From: "Michael S. Tsirkin" Cc: "David S. Miller" , Eric Dumazet , Ben Hutchings , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: fix memory leak on oom with zerocopy Message-ID: <20120916084416.GA22936@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 To: unlisted-recipients:; (no To-header on input) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- Fixes a memory leak so 3.6 material? net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 8398836..899f827 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -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 {