From patchwork Fri May 5 09:57:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 9713265 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 1E319602B9 for ; Fri, 5 May 2017 09:58:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D8DE28616 for ; Fri, 5 May 2017 09:58:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2257628688; Fri, 5 May 2017 09:58:24 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A91B428616 for ; Fri, 5 May 2017 09:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9Kck2C72Cy5h1avpi/eDfXrpRvO/tXu3FhSgY8DIKH8=; b=UtPheX9QuTkxH8GWUQAFzvb+Ej ICaYCnudr1VkQjSoKWwp36y5J2Q/SEorEwvxi35crL5Y5Yj9u+S3xYWA7BND1HIS2+z4VAfTvh2zJ c5OD7ZNQEA6RBTya1Ky4SAMvGAf/Y/RBNy3yr63u8nm3u2kmPPUOo33pPz7fA6Alj7eMEMTZkK6fD 61E9nkBjz7pqd9NAZKX3flQzebDV+Zo7itNGfv6yZZNkrtu25pe9o5lShfD3qzWMjI2pT84f7bGMc 4K511kz7hhu5TPqCpTFwKNv2gW8WcKE0TeZvjkLNbOvcmUeDjVaKueQasUzxvDYYNrAsLxxQQXuxZ Bgn9W4hg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d6a0F-0002XG-66; Fri, 05 May 2017 09:58:23 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d6a0C-0002Wq-VQ for linux-arm-kernel@bombadil.infradead.org; Fri, 05 May 2017 09:58:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hM/N1CjR+VPTu7qjaY9yT88EiOwXBjd0Hg30YaU/9Zw=; b=XFOvwV0JQhRo7ADBUmW5YDMM8 HYD232f+k+ckP5WuL5ReArBaSLP4eJKwfnqDHr4okm7VZi9V3P47YtxERHA/NEJ6dQANmmjk7eIfB yrOvbkbPtwiMoEsBi/AocNUAc0PZZvdnADY+dfjPM3dl5/hDagtKNvdJiUNdHU/r4aOS7Hc16aqgt +xUwHHHlGqvJJ9Pz31f5ts4KWh1Yqgk0L8jStbyc6+BuGrDXk+HGnawMDCcv1RPvPMuYQUmgQI3pz b8J5qkXOY3cZoxiJmW8w8QD2D8yWqGHXmFc3u4+AXEvjkrKm4cuplf76mlVcDM5ZipM8UXPHnX0ug OHPEUp/ug==; Received: from mail.free-electrons.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d6a0B-00039F-Gz for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2017 09:58:20 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id D8256212E0; Fri, 5 May 2017 11:57:56 +0200 (CEST) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id B52D1206EF; Fri, 5 May 2017 11:57:56 +0200 (CEST) From: Thomas Petazzoni To: Vinod Koul , dmaengine@vger.kernel.org Subject: [PATCH 01/10] dma: mv_xor_v2: handle mv_xor_v2_prep_sw_desc() error properly Date: Fri, 5 May 2017 11:57:44 +0200 Message-Id: <1493978274-12805-2-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493978274-12805-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1493978274-12805-1-git-send-email-thomas.petazzoni@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170505_055819_661032_DBD0ADF9 X-CRM114-Status: GOOD ( 10.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni , Andrew Lunn , Yehuda Yitschak , Jason Cooper , Hanna Hawa , stable@vger.kernel.org, Nadav Haklai , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The mv_xor_v2_prep_sw_desc() is called from a few different places in the driver, but we never take into account the fact that it might return NULL. This commit fixes that, ensuring that we don't panic if there are no more descriptors available. Fixes: 19a340b1a820 ("dmaengine: mv_xor_v2: new driver") Cc: Signed-off-by: Thomas Petazzoni --- drivers/dma/mv_xor_v2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c index a28a01f..e928020 100644 --- a/drivers/dma/mv_xor_v2.c +++ b/drivers/dma/mv_xor_v2.c @@ -389,6 +389,8 @@ mv_xor_v2_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, __func__, len, &src, &dest, flags); sw_desc = mv_xor_v2_prep_sw_desc(xor_dev); + if (!sw_desc) + return NULL; sw_desc->async_tx.flags = flags; @@ -443,6 +445,8 @@ mv_xor_v2_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src, __func__, src_cnt, len, &dest, flags); sw_desc = mv_xor_v2_prep_sw_desc(xor_dev); + if (!sw_desc) + return NULL; sw_desc->async_tx.flags = flags; @@ -491,6 +495,8 @@ mv_xor_v2_prep_dma_interrupt(struct dma_chan *chan, unsigned long flags) container_of(chan, struct mv_xor_v2_device, dmachan); sw_desc = mv_xor_v2_prep_sw_desc(xor_dev); + if (!sw_desc) + return NULL; /* set the HW descriptor */ hw_descriptor = &sw_desc->hw_desc;