Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1257035rwb; Thu, 18 Aug 2022 23:41:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR5SY8H6d53RaljDuHYeXMzxSvfUBaYGhZ2cT+72fXXyEawyU8UPOWXUT9XnieK9H8W33c6Q X-Received: by 2002:a17:907:1361:b0:730:e5c4:6eba with SMTP id yo1-20020a170907136100b00730e5c46ebamr3935686ejb.597.1660891314549; Thu, 18 Aug 2022 23:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660891314; cv=none; d=google.com; s=arc-20160816; b=VIQ7VcvT96Ga9+uz5CVix0qD+ogKdHIy1bmaml6Wdr0fHpmGM4B1fFbkqOzMYGb7Sk xdLxCucE0ZghJ7n6qIkBkMbLqWWD/Il02iMgjZRJWxlHIRE0yh/W28NrsSZ8uE8RlSxN cZHxYx7VwZw6oT8xHIK2Iem4811IHP3gLmYi1j9BgUYy+DazbBZfQWnKBFD/xXStbzt6 E5+1QPDfkjjbupSMOKX71gelv2wiC699RSkat9f5KxO5VbhLDfocpafJAhR02L6/54HH BijkElxc8zT3S20DHt/vpwp0YS3c1UIL8yFt14tg+wj3UONfNy5LIB/ZXzHnAOWGGtTr GaAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zxM42Y9uEm9HYeKUiC4xFIG7yPyezX+CS6v5K5nZU8U=; b=j0YBv+qG5pcz0UOxBkWRua8fxaxkwrZhihSCCFVJr1gta4b2nP4G7D7rZqZTOqWUVv E6/g87jJYmO2b0fcdVwEobOs8hykFsLI+1a/FyukktMyPhlrIFo/EiSq3lGEzYjVl3ES 5KytzfYLFguEtdvw8+FMRqV2bhZmzIeCK6jdrkGDlRKUK7aAVxC4q2nUF7lTZpqpJJ+h AQrfGoe6cC3NKKkshcKUIXFJawlIIC6lB0Rw6sTzri+RJwuweecORA2ypkhJP1LckBDi rTZNktUUqoSTLDxjCqYLnpzyI3STfcyBd7tkvreuAojemecnWgRAUtbdJvwPR2F2LfQ2 StXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=DP1gLMIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ionos.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020a170906794e00b00732f6d8454fsi2858476ejo.656.2022.08.18.23.41.28; Thu, 18 Aug 2022 23:41:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=DP1gLMIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ionos.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346559AbiHSGIo (ORCPT + 99 others); Fri, 19 Aug 2022 02:08:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345268AbiHSGIM (ORCPT ); Fri, 19 Aug 2022 02:08:12 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28AE723F for ; Thu, 18 Aug 2022 23:08:11 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id kb8so6993326ejc.4 for ; Thu, 18 Aug 2022 23:08:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=zxM42Y9uEm9HYeKUiC4xFIG7yPyezX+CS6v5K5nZU8U=; b=DP1gLMIPVWB7ZYRop6oPt9NMumqgtsCGEOsM4vtsybhCRs5Dzp0CsQyLxargAIZINe ODmtV6u0iTI76C8ByXG7V1u+ccKF2e4qad3XsUzDIL6hye4OHE21JrXHHI932pE31adz R5XPcDmOIlBlW11EAcwZZ7lNflcuox+CFV9XjBDIN+0uCxGBFeyNFx2ldpUzzJncXSE0 1qtTuvw6sM8xrgjoFNXPjTWjVc/9E1DWxISdgmYV5jaFfPcDxncJ6b7lwd3QEA0UaswE kDGyILqBu+97OQjN5PmYrcF4nGuApHE1R3j50OpsFP7F3eX1tJg1XxbfZIv3QdZxdek/ 84fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=zxM42Y9uEm9HYeKUiC4xFIG7yPyezX+CS6v5K5nZU8U=; b=08Y5u+r5Zd7kTGCj4urtUaA/TXR/5whchVIpz56yvsuf9Eick3WA90QiadIkDTZoKX PFXN/cGKCOuiANIrjWGX3oTt9tw1NM1V5pOG8gII+bWIDxMwnHDVvcBbZgAaRkg857it z44pg/iqOEUwnnPzSLbqV51Scvmi7Owps026p7jhJJUIveJgKduas9LHJOKT/gIsROot Rigr52wC0FEw9gHeY35DXhYBlCUO6Z4sz4b0HP7Lyi0zzL7unD67bVflsvYB5J1oBlzc eQx5sDpLcwDymF+poYKfajwlVL/V1SASJwJSCrpdy+MOqI05LhuatJEZdKChkUhcPUyG Er1w== X-Gm-Message-State: ACgBeo2792JA5mL7GlnffrgqZgjDV/10IbyVDTfrJ55EKajE4cExMGt9 37jfcK44mlGLEv4uSyEJfRlxewDiP+qndg== X-Received: by 2002:a17:906:5d07:b0:738:b86d:df3d with SMTP id g7-20020a1709065d0700b00738b86ddf3dmr3767679ejt.617.1660889289504; Thu, 18 Aug 2022 23:08:09 -0700 (PDT) Received: from lb02065.fritz.box ([2001:9e8:143b:fd00:5207:8c7f:747a:b80d]) by smtp.gmail.com with ESMTPSA id y14-20020a1709063a8e00b0073a644ef803sm1809660ejd.101.2022.08.18.23.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 23:08:08 -0700 (PDT) From: Jack Wang To: linux-kernel@vger.kernel.org Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Maxime Coquelin , Alexandre Torgue , Philipp Zabel , Christophe Kerello , Cai Huoqing , linux-mtd@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v1 05/19] mtd: rawnand: marvell: Fix error handle regarding dma_map_sg Date: Fri, 19 Aug 2022 08:07:47 +0200 Message-Id: <20220819060801.10443-6-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819060801.10443-1-jinpu.wang@ionos.com> References: <20220819060801.10443-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dma_map_sg return 0 on error, in case of error return -EIO, also add the dma_unmap_sg as rollback on the following error. Cc: Miquel Raynal Cc: Richard Weinberger Cc: Vignesh Raghavendra Cc: Maxime Coquelin Cc: Alexandre Torgue Cc: Philipp Zabel Cc: Christophe Kerello Cc: Cai Huoqing Cc: linux-mtd@lists.infradead.org Cc: linux-stm32@st-md-mailman.stormreply.com Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Jack Wang --- drivers/mtd/nand/raw/marvell_nand.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c index 2455a581fd70..d9f2f1d0b5ef 100644 --- a/drivers/mtd/nand/raw/marvell_nand.c +++ b/drivers/mtd/nand/raw/marvell_nand.c @@ -865,13 +865,19 @@ static int marvell_nfc_xfer_data_dma(struct marvell_nfc *nfc, marvell_nfc_enable_dma(nfc); /* Prepare the DMA transfer */ sg_init_one(&sg, nfc->dma_buf, dma_len); - dma_map_sg(nfc->dma_chan->device->dev, &sg, 1, direction); + ret = dma_map_sg(nfc->dma_chan->device->dev, &sg, 1, direction); + if (!ret) { + dev_err(nfc->dev, "Could not map DMA S/G list\n"); + return -ENXIO; + } + tx = dmaengine_prep_slave_sg(nfc->dma_chan, &sg, 1, direction == DMA_FROM_DEVICE ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT); if (!tx) { dev_err(nfc->dev, "Could not prepare DMA S/G list\n"); + dma_unmap_sg(nfc->dma_chan->device->dev, &sg, 1, direction); return -ENXIO; } -- 2.34.1