Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752595AbdHHOh0 (ORCPT ); Tue, 8 Aug 2017 10:37:26 -0400 Received: from m12-11.163.com ([220.181.12.11]:55463 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752390AbdHHOhZ (ORCPT ); Tue, 8 Aug 2017 10:37:25 -0400 From: Pan Bian To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Pan Bian Subject: mtd: nand: use dma_mapping_error to check map errors Date: Tue, 8 Aug 2017 22:35:42 +0800 Message-Id: <1502202942-23984-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: C8CowAAH5QFMzIlZDK7qCQ--.49881S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Gry8Wr48Xr18XFyxWF13CFg_yoWfCFb_Gr 4jvrs7Krs7ArnrAw1SgFy3AryakrWUuF4xZF1qqasIkay3ZFyIqry0vFn8Crn7ZF129FZx Jr98AayIyrsrZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnUPEDUUUUU== X-Originating-IP: [106.120.213.24] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBZBMuclQG9fTMbwAAsb Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 864 Lines: 25 The return value of dma_map_single() should be checked by dma_mapping_error(). However, in function flctl_dma_fifo0_transfer(), its return value is checked against NULL, which could result in failures. Signed-off-by: Pan Bian --- drivers/mtd/nand/sh_flctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c index 891ac7b..2404d66 100644 --- a/drivers/mtd/nand/sh_flctl.c +++ b/drivers/mtd/nand/sh_flctl.c @@ -411,7 +411,7 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf, dma_addr = dma_map_single(chan->device->dev, buf, len, dir); - if (dma_addr) + if (!dma_mapping_error(chan->device->dev, dma_addr)) desc = dmaengine_prep_slave_single(chan, dma_addr, len, tr_dir, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); -- 1.9.1