From patchwork Wed Jul 20 08:51:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 105602 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 683ACB6F77 for ; Wed, 20 Jul 2011 18:54:01 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751217Ab1GTIxt (ORCPT ); Wed, 20 Jul 2011 04:53:49 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:52654 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750745Ab1GTIxs (ORCPT ); Wed, 20 Jul 2011 04:53:48 -0400 Received: by wyg8 with SMTP id 8so8086wyg.19 for ; Wed, 20 Jul 2011 01:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=yNIZ0182uVoBrFESLi1rvlWKbbiKBEuyMWCEcYQv4dw=; b=nuhvO2U5yE/lIH9xPRXYgNgfcbC5Ra3CUmlyqExjfjqdhjppSG2Gxb+sL6c6WrgvsD 4tr2821WYniLc9rwWtB3z4xCGO14SZNMaWaEG4+10Pgpo/dcYrBHaeheveC9/cP/FAjF vRVvbvczTJeGBrDayA5fraRY8qaQh2TRqGHOg= Received: by 10.216.137.40 with SMTP id x40mr364075wei.20.1311152027090; Wed, 20 Jul 2011 01:53:47 -0700 (PDT) Received: from shale.localdomain ([41.202.225.152]) by mx.google.com with ESMTPS id w8sm11472wec.0.2011.07.20.01.53.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jul 2011 01:53:46 -0700 (PDT) Date: Wed, 20 Jul 2011 11:51:49 +0300 From: Dan Carpenter To: Shirley Ma Cc: "David S. Miller" , Eric Dumazet , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , "open list:NETWORKING [GENERAL]" , kernel-janitors@vger.kernel.org Subject: [patch net-next-2.6 v2] skbuff: fix error handling in pskb_copy() Message-ID: <20110720085149.GI6445@shale.localdomain> References: <20110720072343.GF6445@shale.localdomain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110720072343.GF6445@shale.localdomain> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There are two problems: 1) "n" was allocated with alloc_skb() so we should free it with kfree_skb() instead of regular kfree(). 2) We return the freed pointer instead of NULL. Signed-off-by: Dan Carpenter Reviewed-by: Eric Dumazet --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/skbuff.c b/net/core/skbuff.c index d220119..2beda82 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -799,7 +799,8 @@ struct sk_buff *pskb_copy(struct sk_buff *skb, gfp_t gfp_mask) if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { if (skb_copy_ubufs(skb, gfp_mask)) { - kfree(n); + kfree_skb(n); + n = NULL; goto out; } skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY;