From patchwork Fri Jan 18 07:46:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 1999901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 2040ADF280 for ; Fri, 18 Jan 2013 07:49:14 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tw6f5-0005Ht-PT; Fri, 18 Jan 2013 07:46:51 +0000 Received: from norkia.v3.sk ([91.210.183.14]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Tw6ep-0005Dr-3I for linux-arm-kernel@lists.infradead.org; Fri, 18 Jan 2013 07:46:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by norkia.v3.sk (Postfix) with ESMTP id EE60712A0EA; Fri, 18 Jan 2013 08:46:33 +0100 (CET) X-Virus-Scanned: amavisd-new at v3.sk Received: from norkia.v3.sk ([127.0.0.1]) by localhost (norkia.v3.sk [127.0.0.1]) (amavisd-new, port 10024) with SMTP id f6XRgy40ot2X; Fri, 18 Jan 2013 08:46:31 +0100 (CET) Received: from localhost.localdomain (ip-94-113-108-27.net.upcbroadband.cz [94.113.108.27]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: lkundrak@v3.sk) by norkia.v3.sk (Postfix) with ESMTP id 2714B12A0E7; Fri, 18 Jan 2013 08:46:31 +0100 (CET) From: Lubomir Rintel To: Thomas Petazzoni Subject: [PATCH 2/3] dma: mv_xor: fix DMA-API error handling sanity check Date: Fri, 18 Jan 2013 08:46:21 +0100 Message-Id: <1358495182-30964-2-git-send-email-lkundrak@v3.sk> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1358495154.28503.5.camel@unicorn> References: <1358495154.28503.5.camel@unicorn> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130118_024635_419069_4BE5523C X-CRM114-Status: GOOD ( 11.55 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Vinod Koul , Lubomir Rintel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Dan Williams X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add error checking. --- drivers/dma/mv_xor.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c index 8b81a04..d00a834 100644 --- a/drivers/dma/mv_xor.c +++ b/drivers/dma/mv_xor.c @@ -939,9 +939,21 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) dest_dma = dma_map_single(dma_chan->device->dev, dest, MV_XOR_TEST_SIZE, DMA_FROM_DEVICE); + if (dma_mapping_error(dma_chan->device->dev, dest_dma)) { + dev_err(dma_chan->device->dev, + "Could not map destination buffer, disabling\n"); + err = -ENODEV; + goto free_resources; + } src_dma = dma_map_single(dma_chan->device->dev, src, MV_XOR_TEST_SIZE, DMA_TO_DEVICE); + if (dma_mapping_error(dma_chan->device->dev, src_dma)) { + dev_err(dma_chan->device->dev, + "Could not map source buffer, disabling\n"); + err = -ENODEV; + goto free_resources; + } tx = mv_xor_prep_dma_memcpy(dma_chan, dest_dma, src_dma, MV_XOR_TEST_SIZE, @@ -1031,10 +1043,23 @@ mv_xor_xor_self_test(struct mv_xor_chan *mv_chan) /* test xor */ dest_dma = dma_map_page(dma_chan->device->dev, dest, 0, PAGE_SIZE, DMA_FROM_DEVICE); + if (dma_mapping_error(dma_chan->device->dev, dest_dma)) { + dev_err(dma_chan->device->dev, + "Could not map destination page, disabling\n"); + err = -ENODEV; + goto free_resources; + } - for (i = 0; i < MV_XOR_NUM_SRC_TEST; i++) + for (i = 0; i < MV_XOR_NUM_SRC_TEST; i++) { dma_srcs[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i], 0, PAGE_SIZE, DMA_TO_DEVICE); + if (dma_mapping_error(dma_chan->device->dev, dma_srcs[i])) { + dev_err(dma_chan->device->dev, + "Could not map source page, disabling\n"); + err = -ENODEV; + goto free_resources; + } + } tx = mv_xor_prep_dma_xor(dma_chan, dest_dma, dma_srcs, MV_XOR_NUM_SRC_TEST, PAGE_SIZE, 0);