From patchwork Sun Sep 24 06:26:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 9967751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 468F36020C for ; Sun, 24 Sep 2017 06:28:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 389AE28F44 for ; Sun, 24 Sep 2017 06:28:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D63A28F5F; Sun, 24 Sep 2017 06:28:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB27528F44 for ; Sun, 24 Sep 2017 06:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751490AbdIXG2f (ORCPT ); Sun, 24 Sep 2017 02:28:35 -0400 Received: from smtp10.smtpout.orange.fr ([80.12.242.132]:23095 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751267AbdIXG2e (ORCPT ); Sun, 24 Sep 2017 02:28:34 -0400 Received: from localhost.localdomain ([86.196.182.67]) by mwinf5d33 with ME id DJUM1w0021TfVo603JUQqA; Sun, 24 Sep 2017 08:28:32 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 24 Sep 2017 08:28:32 +0200 X-ME-IP: 86.196.182.67 From: Christophe JAILLET To: vinod.koul@intel.com, dan.j.williams@intel.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] dmaengine: imx-sdma: Report a DMA_ERROR in status if 'count' or 'dma_address' do not match DMA_SLAVE_BUSWIDTH Date: Sun, 24 Sep 2017 08:26:41 +0200 Message-Id: <20170924062641.30187-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.11.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All sanity checks in this function set 'sdmac->status = DMA_ERROR' if something looks wrong, except if the byte count or the address don't match the bus width. Fix it and report the error in status in such a case. Signed-off-by: Christophe JAILLET --- Untested, so please review carefuly. --- drivers/dma/imx-sdma.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index a67ec1bdc4e0..f0419967eb92 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1240,26 +1240,31 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg( sdmac->chn_count += count; if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES) { - ret = -EINVAL; + ret = -EINVAL; goto err_out; } switch (sdmac->word_size) { case DMA_SLAVE_BUSWIDTH_4_BYTES: bd->mode.command = 0; - if (count & 3 || sg->dma_address & 3) - return NULL; + if (count & 3 || sg->dma_address & 3) { + ret = -EINVAL; + goto err_out; + } break; case DMA_SLAVE_BUSWIDTH_2_BYTES: bd->mode.command = 2; - if (count & 1 || sg->dma_address & 1) - return NULL; + if (count & 1 || sg->dma_address & 1) { + ret = -EINVAL; + goto err_out; + } break; case DMA_SLAVE_BUSWIDTH_1_BYTE: bd->mode.command = 1; break; default: - return NULL; + ret = -EINVAL; + goto err_out; } param = BD_DONE | BD_EXTD | BD_CONT;