From patchwork Thu Nov 26 18:08:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 7708421 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A0101BF90C for ; Thu, 26 Nov 2015 18:12:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7C6F20686 for ; Thu, 26 Nov 2015 18:12:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EEF1520622 for ; Thu, 26 Nov 2015 18:12:01 +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 1a20zh-00058c-8F; Thu, 26 Nov 2015 18:10:09 +0000 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a20yP-0003za-5T for linux-arm-kernel@lists.infradead.org; Thu, 26 Nov 2015 18:08:50 +0000 Received: by lffu14 with SMTP id u14so105856402lff.1 for ; Thu, 26 Nov 2015 10:08:27 -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=xk/83gMht/ZuImziGBecuEzMIA+FAjRqXcUYfikpwQQ=; b=YryRbObtY3E1JRl8RJdHVVXI7cLiH4XQLWqm0z0Y7mx2ijC/V1K1NbvDveSkkeog3Z ZLb6Sh8u2n1nvg3bvvC6XzTKq1rqFLamJCQ6FJ1l0C5XiAZUUAKO5VbnU0gT8srkx5w6 mVc1LB3kZCTVPwwq1lz5YKTEzGJvfpz/wUHye0pMIU6lb+ubXGlgrmLjMlQjB9Zs+0+q U5ZzbcaEbRODtYoQ7EzSQL8NK6T9tv4jEHdibtr854FRP8QuCwNHupHVHMosRv5dPM7e HXdo6xLGtSOAPxiCi6p8dJS8xIFHX4rv6FoTw4o0udFgccDJ/e/INqK/ncrqHirM8t/d 58zQ== 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=xk/83gMht/ZuImziGBecuEzMIA+FAjRqXcUYfikpwQQ=; b=e6IAM5RVrZsTLLbW6325Zh/w9ZpnS6QvmuyqPJnbGOSw4LQpD2EwTFJ4mLKOFA5igx ck/Vz0UvUG/WJuynG3mNFrAJoonnmDTJbfINqPBHHmVUDkbAcXm7w+WVJV1kIZRR8Ax5 pLbOjPfwxw0zQgSo/Fw23ShrkRLocPkyCdEiEJeGj4TVqKsZeEhthBVNtPHA/1D+L8bu z5C7cwwMw1LM+8jbXjSjHmxZNGN7I65cEVmya4tmVQYDddFgcp3A7iXVmn/SmOAUBy6C GW1UiC4ANor5LERabfQqS73Kd0Bsg591uI2LRtJBhFTtQYtC81LYYhuYPaVJuWhxjEI7 w5pw== X-Gm-Message-State: ALoCoQk+p5Fmk0YSd1nVZZ5GT6+4DntZEXFdwO3okhUlfGOEnnwhAifZrAt25+CWsB6eJgO3a0BD X-Received: by 10.25.79.17 with SMTP id d17mr18901370lfb.40.1448561307114; Thu, 26 Nov 2015 10:08:27 -0800 (PST) Received: from enkidu.semihalf.local ([80.82.22.190]) by smtp.gmail.com with ESMTPSA id a190sm4297654lfa.32.2015.11.26.10.08.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Nov 2015 10:08:26 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [PATCH v2 net 4/6] net: mvneta: fix error path for building skb Date: Thu, 26 Nov 2015 19:08:11 +0100 Message-Id: <1448561293-16431-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1448561293-16431-1-git-send-email-mw@semihalf.com> References: <1448561293-16431-1-git-send-email-mw@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151126_100849_584701_76A5A1BE X-CRM114-Status: GOOD ( 12.75 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch, linux@arm.linux.org.uk, jason@lakedaemon.net, myair@marvell.com, jaz@semihalf.com, simon.guinot@sequanux.org, xswang@marvell.com, nadavh@marvell.com, alior@marvell.com, stable@vger.kernel.org, tn@semihalf.com, gregory.clement@free-electrons.com, nitroshift@yahoo.com, mw@semihalf.com, davem@davemloft.net, sebastian.hesselbarth@gmail.com 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=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 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 Cc: # v4.2+ Fixes a84e32894191 ("net: mvneta: fix refilling for Rx DMA buffers") Acked-by: Simon Guinot --- 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 0c3d923..62cf971 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;