Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1411781yba; Tue, 2 Apr 2019 08:23:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwU20muzOwDa5CpDZNjU7TdmnPsz0Sma/fNnMpL2S99Fq+KiWG3i1KfN/qY6RAlfCWMgE3o X-Received: by 2002:a63:1f52:: with SMTP id q18mr68248948pgm.134.1554218603201; Tue, 02 Apr 2019 08:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554218603; cv=none; d=google.com; s=arc-20160816; b=NQmj8gK0y8ojBLIZnk4ZKjh+CCU4g2U9crR7dqH/4jp8eDrrOfVBrfCKF/Pvr7wCFq Wt3d+OVKGJrFxzeWcmTKaqnBjLcZfLvHtd/u0ZdOxmAL1D9/42+oGdj2lsVWOeseA6mp Mm53aI/M2z8GSlZArgpF+dKTgAW01Nf0RO1fMYIVjofKtT4eh56iB2ndRTFxzwpeeX+O bBla6MipKiKiUBB+NWCEQVfQV3b6djm1Kx6W7aThDbb5Xig4pja7QYL0Gxpfk5XjX63x l0kRmo3HcvEaS8ydwByeLO4c5ODXp1xOmrTQ/Vfsraew7Oaf+7hxM1z2yPlbgIGhE+Xn FyTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=hfrdcOdmZGJ4YKgG0zKXIImWIEeoAYqZtZJcb6dHtg4=; b=axYtA8vUc92oe485haHoUM863zV8wVKayYY42Nvyo4/Fo1goDMlssppbsBs+PnZuox oR4NEQ5J7pTtLkFSVOGMU5esva1SPXpydWOsGAw9nRxKLk5dBDY6WR3k/0C/ELvATPw/ qdfHQN0Lb5cYH3llM+u3QAYEvPq47rmDXtnFTFr9QPJ/j+ja2H/WJbzGaq662VzbwEQ2 fr/+1wWrKcwYFBMl53Gv9E9tZzI/8ArjBVJ8ERuHBLjMYRW6GzkWRgoWnIDMoBe4SETh NVF5GKRum5rbDSHW2dN/XkPsHENK+7lWyr4F11pNCfWcBynp9+r5YIPuChWzlKRYttBB csGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 130si11216023pgc.256.2019.04.02.08.23.07; Tue, 02 Apr 2019 08:23:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731693AbfDBNkh (ORCPT + 99 others); Tue, 2 Apr 2019 09:40:37 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43592 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728817AbfDBNkL (ORCPT ); Tue, 2 Apr 2019 09:40:11 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJe3-0002oa-U4; Tue, 02 Apr 2019 14:40:08 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdy-0004xx-48; Tue, 02 Apr 2019 14:40:02 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "David S. Miller" , "Tyrel Datwyler" Date: Tue, 02 Apr 2019 14:38:28 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 93/99] ibmveth: fix DMA unmap error in ibmveth_xmit_start error path In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Tyrel Datwyler commit 756af9c642329d54f048bac2a62f829b391f6944 upstream. Commit 33a48ab105a7 ("ibmveth: Fix DMA unmap error") fixed an issue in the normal code path of ibmveth_xmit_start() that was originally introduced by Commit 6e8ab30ec677 ("ibmveth: Add scatter-gather support"). This original fix missed the error path where dma_unmap_page is wrongly called on the header portion in descs[0] which was mapped with dma_map_single. As a result a failure to DMA map any of the frags results in a dmesg warning when CONFIG_DMA_API_DEBUG is enabled. ------------[ cut here ]------------ DMA-API: ibmveth 30000002: device driver frees DMA memory with wrong function [device address=0x000000000a430000] [size=172 bytes] [mapped as page] [unmapped as single] WARNING: CPU: 1 PID: 8426 at kernel/dma/debug.c:1085 check_unmap+0x4fc/0xe10 ... ... DMA-API: Mapped at: ibmveth_start_xmit+0x30c/0xb60 dev_hard_start_xmit+0x100/0x450 sch_direct_xmit+0x224/0x490 __qdisc_run+0x20c/0x980 __dev_queue_xmit+0x1bc/0xf20 This fixes the API misuse by unampping descs[0] with dma_unmap_single. Fixes: 6e8ab30ec677 ("ibmveth: Add scatter-gather support") Signed-off-by: Tyrel Datwyler Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- drivers/net/ethernet/ibm/ibmveth.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -1059,11 +1059,15 @@ out: map_failed_frags: last = i+1; - for (i = 0; i < last; i++) + for (i = 1; i < last; i++) dma_unmap_page(&adapter->vdev->dev, descs[i].fields.address, descs[i].fields.flags_len & IBMVETH_BUF_LEN_MASK, DMA_TO_DEVICE); + dma_unmap_single(&adapter->vdev->dev, + descs[0].fields.address, + descs[0].fields.flags_len & IBMVETH_BUF_LEN_MASK, + DMA_TO_DEVICE); map_failed: if (!firmware_has_feature(FW_FEATURE_CMO)) netdev_err(netdev, "tx: unable to map xmit buffer\n");