From patchwork Mon Jul 7 23:23:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 4498591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A93E99F26C for ; Mon, 7 Jul 2014 23:26:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D536820328 for ; Mon, 7 Jul 2014 23:26:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12460202FF for ; Mon, 7 Jul 2014 23:26:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4IGf-0003Hy-Dw; Mon, 07 Jul 2014 23:24:17 +0000 Received: from pandora.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4IGB-0002V4-UW for linux-arm-kernel@lists.infradead.org; Mon, 07 Jul 2014 23:23:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Subject:Cc:To:From:References:In-Reply-To; bh=i9IZdNBCKWBO8Ha9uGqWDCtuHSA1ywv3o+0XhDQD+7g=; b=D4HgQTaRbNKUwq8NGNsHRkpWphUaHxgxvjmoyNcXHXeek7bUgGyOXhrT2S6MvifnsY78/xK31mOVXRDflRRoU9pz9eDi3mnAagRqQ2yGveYqIOTUUMOnuZnFIkG5gtIouqdtmyC3YvIHaklmON+vDrB7OZIC4C4o96UzyMn69Nk=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:48941 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1X4IFp-0005Bs-Dr; Tue, 08 Jul 2014 00:23:25 +0100 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1X4IFp-0004xM-2c; Tue, 08 Jul 2014 00:23:25 +0100 In-Reply-To: <20140707232148.GG21766@n2100.arm.linux.org.uk> References: <20140707232148.GG21766@n2100.arm.linux.org.uk> From: Russell King To: "David S. Miller" Subject: [PATCH A 11/12] net: fec: ensure fec_enet_free_buffers() properly cleans the rings Message-Id: Date: Tue, 08 Jul 2014 00:23:25 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140707_162348_257078_CE3C9429 X-CRM114-Status: GOOD ( 12.59 ) X-Spam-Score: -0.8 (/) Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ensure that we do not double-free any allocations, and that any transmit skbuffs are properly freed when we clean up the rings. Acked-by: Fugang Duan Signed-off-by: Russell King --- drivers/net/ethernet/freescale/fec_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 9c5570a3e32e..5499bd8ad0a5 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2079,8 +2079,13 @@ static void fec_enet_free_buffers(struct net_device *ndev) } bdp = fep->tx_bd_base; - for (i = 0; i < fep->tx_ring_size; i++) + for (i = 0; i < fep->tx_ring_size; i++) { kfree(fep->tx_bounce[i]); + fep->tx_bounce[i] = NULL; + skb = fep->tx_skbuff[i]; + fep->tx_skbuff[i] = NULL; + dev_kfree_skb(skb); + } } static int fec_enet_alloc_buffers(struct net_device *ndev)