From patchwork Mon Nov 30 12:27:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 549979 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 B909A1401AF for ; Mon, 30 Nov 2015 23:29:11 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b=bDB3VsfO; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754120AbbK3M2x (ORCPT ); Mon, 30 Nov 2015 07:28:53 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:34908 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754040AbbK3M1q (ORCPT ); Mon, 30 Nov 2015 07:27:46 -0500 Received: by lfdl133 with SMTP id l133so193329866lfd.2 for ; Mon, 30 Nov 2015 04:27:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Bxc8VbPjt6q0YHieHi6DQ8tIfTOGeGzDlvbpGwSZDA8=; b=bDB3VsfO7znCzzJKIVZR5cQqsPv1lhOFQO3ROjyazJGg4lsTWRj2CuDRstze352Gd5 t6DFzSwD2N06lenmFt1ucFTX5ipVXy7QWNXg5290KF2NcuZCQu9zK47HrxACzh1930Cw PMv39tQjpIhLaM5nT7rSF3XDfzs9OHJpNqaAXwn/vews5BqTK9uJzMcJOYtuUuvEAutu AOZoWKyu3Ypqpdlu98zvCnvmpEERwd/23OM45DaOcaH+cbkeZHseG8F+JrHSmx6FhZnI 3a5soOgtD60Wq/2drMbOAAoNHTTM7QMcvC5P5cTNkKoVe3itFOQTcfyHZFui3mzGePbv RDBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Bxc8VbPjt6q0YHieHi6DQ8tIfTOGeGzDlvbpGwSZDA8=; b=IZwR6uplC0OOIppcIWcq2Lg/+sHPL4O6ZpAdbw/h03t3vz8hf2szCe+T3DCXMmeCE4 YcTi4n86BnwboH3AcO6zret6Okfkk4KUmnwlozR5c9WRISxkYaKGxGG+Jx1vGO4WzF78 prhtxZEw6DbKzg5U3QDdEwmfQ6W/Pd6gkf4f+MvGsR1ERi/lzWnGkgIqCNHXy9EQimaQ ScEgLLEii7ggMV2k+0c7KSPkeL4ANBch6VE1bSsYJ5UuiE2d7VFkYrz/w6oLUKmA7vcX NjomM3g1/X2PrrJPfQrcFa33Etch2JvaopgxsFymYytCSsX0act2yYeB8Q4Pou9Ydyfy fKEg== X-Gm-Message-State: ALoCoQki849bfsRCRM6b5yuniWhrrfcYlpbuf4LYG1zYizX9zA7EBOwvVT9cvrnqPv01ucTp/Mpa X-Received: by 10.25.26.68 with SMTP id a65mr13913980lfa.72.1448886464876; Mon, 30 Nov 2015 04:27:44 -0800 (PST) Received: from enkidu.semihalf.local ([80.82.22.190]) by smtp.gmail.com with ESMTPSA id l67sm7325249lfl.26.2015.11.30.04.27.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Nov 2015 04:27:44 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Cc: davem@davemloft.net, linux@arm.linux.org.uk, sebastian.hesselbarth@gmail.com, andrew@lunn.ch, jason@lakedaemon.net, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, simon.guinot@sequanux.org, nadavh@marvell.com, alior@marvell.com, xswang@marvell.com, myair@marvell.com, nitroshift@yahoo.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Subject: [PATCH v4 net 4/6] net: mvneta: fix error path for building skb Date: Mon, 30 Nov 2015 13:27:44 +0100 Message-Id: <1448886466-31538-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1448886466-31538-1-git-send-email-mw@semihalf.com> References: <1448886466-31538-1-git-send-email-mw@semihalf.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In the actual RX processing, there is same error path for both descriptor ring refilling and building skb fails. This is not correct, because after successful refill, the ring is already updated with newly allocated buffer. Then, in case of build_skb() fail, hitherto code left the original buffer unmapped. This patch fixes above situation by swapping error check of skb build with DMA-unmap of original buffer. Signed-off-by: Marcin Wojtas Acked-by: Simon Guinot Cc: # v4.2+ Fixes a84e32894191 ("net: mvneta: fix refilling for Rx DMA buffers") --- drivers/net/ethernet/marvell/mvneta.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 5dffb68..5a98c5d 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -1580,12 +1580,16 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo, } skb = build_skb(data, pp->frag_size > PAGE_SIZE ? 0 : pp->frag_size); - if (!skb) - goto err_drop_frame; + /* After refill old buffer has to be unmapped regardless + * the skb is successfully built or not. + */ dma_unmap_single(dev->dev.parent, phys_addr, MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE); + if (!skb) + goto err_drop_frame; + rcvd_pkts++; rcvd_bytes += rx_bytes;