Message ID | 20231004163531.2864160-1-amelie.delaunay@foss.st.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp260101vqb; Wed, 4 Oct 2023 09:36:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKPU9Ofg/h6YsmA4a8RSWNbE9rQGqVj1NqOUiItwyojSD+uuaCGmYP8jH2/uD4+7FJ22ti X-Received: by 2002:a05:6a00:181d:b0:68a:48e7:9deb with SMTP id y29-20020a056a00181d00b0068a48e79debmr247339pfa.2.1696437379664; Wed, 04 Oct 2023 09:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696437379; cv=none; d=google.com; s=arc-20160816; b=0hEupVkTh2MonGZ4cLEeQOU/TLVvziMhFY2qk08oMXZXL69wRiP5OYyPis0aR7M1MP YNhDPeGZfqmIpkHhGfyuTQAFhaZujs4tK8VUFgOKoKvaxFtiMHdLIOPim+UcaSUgl0uv VjeSVdK+9d6Fpb1Vo6vGL+iMgF1xHHsHFIncU2lbzgFDmaTPSamr6XaPRmJObfihr/bU 5wgu1fZShXPAOMaX1nWMYCv3w8NFEJCIgR0l2CCVKpJdRhy/kq0JCFC6XMlGR/33RMRm 76VMN8hdtQzZOE+JCwyIC11DfXwW4alpQYtxI/3iUmDcHSMu5dtqnZl4shCDGcypjHSZ SZ7g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=dyiz+tjfiV2jpQFO28ugDVDITHWqIXX0qTTS/2IIaYg=; fh=YvrRAQQ26JPX0Bux3OhUT4qJGOYUgg20XKLY/tObm68=; b=IuAfPomH4C67HDdttQPLF9C/zg5P7Pkusb0IWVYdXY4IxzT4sNIjJ+IPZ5SbYNdyS7 cK6bJ9RwAKFhImb+9tDGVc7LJqX8g2pk2Z8xUsswd5WvJL12OjdprxqP9/cOXUrZj29g LHdt+m5zIj0dJv7E52awQWUaQC/sglDhfYuASn/wmFzKIyU1OJ1jG/z8tnA/tJMSYV8a W4ZlVeAITYRCzn8ERVgATZUiliorTRtC9cY2r4lwyExWAlDffqqdPrPU8PI27GwRd0e0 9cL2sGZ4Rv3lwuyz/DRb4X7BSjVB9V0H/+zhXDQlpNBdtAviztVdCH8UazaAjw09gr2Y 7+EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=CDOyv5d4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e70-20020a636949000000b005855ea4b519si4052069pgc.145.2023.10.04.09.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 09:36:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=CDOyv5d4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CC60A81B800E; Wed, 4 Oct 2023 09:36:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243410AbjJDQgR (ORCPT <rfc822;ezelljr.billy@gmail.com> + 19 others); Wed, 4 Oct 2023 12:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233799AbjJDQgQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 4 Oct 2023 12:36:16 -0400 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 898EB95; Wed, 4 Oct 2023 09:36:10 -0700 (PDT) Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 394AavuA022614; Wed, 4 Oct 2023 18:35:55 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=selector1; bh=dyiz+tj fiV2jpQFO28ugDVDITHWqIXX0qTTS/2IIaYg=; b=CDOyv5d4QUbM1WjCWwIJXBD DSi4ZgqWpzaHg8dky77xXIM/V1dxFE6Jwa6DFlsf8LcOOIwfAVhCHwPOsNlx9I7L TuaYZSCKn67PUjxIlwGj7tZL29EJHgOp6U9ua4zuw7xE/YJe27Mjbi1OHnzAVG/r LBHaRISHLXr0XugucynvryAD+zF6kGZIFAiW8Ga01/x0OcN77OC9dg8PrPF3VOE7 hjNeZ28jaAwLYAbkBU7AFsBiCkD3k2H0PaLldo99UoDJJXkofkfFr9Qh8OgYuxH/ 4qgROhfdwVmzxVGzEaH5Ftegw3sUULVosX+eMrBB68dAZAtidXa58c/Oln4JAkA= = Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3tggx36fju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Oct 2023 18:35:55 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0D065100053; Wed, 4 Oct 2023 18:35:55 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0528A281EB6; Wed, 4 Oct 2023 18:35:55 +0200 (CEST) Received: from localhost (10.252.26.61) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 4 Oct 2023 18:35:54 +0200 From: Amelie Delaunay <amelie.delaunay@foss.st.com> To: Vinod Koul <vkoul@kernel.org>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, M'boumba Cedric Madianga <cedric.madianga@gmail.com>, Pierre-Yves MORDRET <pierre-yves.mordret@st.com> CC: Amelie Delaunay <amelie.delaunay@foss.st.com>, <stable@vger.kernel.org>, <dmaengine@vger.kernel.org>, <linux-stm32@st-md-mailman.stormreply.com>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH 1/3] dmaengine: stm32-mdma: abort resume if no ongoing transfer Date: Wed, 4 Oct 2023 18:35:28 +0200 Message-ID: <20231004163531.2864160-1-amelie.delaunay@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.252.26.61] X-ClientProxiedBy: EQNCAS1NODE4.st.com (10.75.129.82) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-04_08,2023-10-02_01,2023-05-22_02 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 09:36:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778843522204324445 X-GMAIL-MSGID: 1778843522204324445 |
Series |
[1/3] dmaengine: stm32-mdma: abort resume if no ongoing transfer
|
|
Commit Message
Amelie Delaunay
Oct. 4, 2023, 4:35 p.m. UTC
chan->desc can be null, if transfer is terminated when resume is called,
leading to a NULL pointer when retrieving the hwdesc.
To avoid this case, check that chan->desc is not null and channel is
disabled (transfer previously paused or terminated).
Fixes: a4ffb13c8946 ("dmaengine: Add STM32 MDMA driver")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
---
drivers/dma/stm32-mdma.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On Wed, 04 Oct 2023 18:35:28 +0200, Amelie Delaunay wrote: > chan->desc can be null, if transfer is terminated when resume is called, > leading to a NULL pointer when retrieving the hwdesc. > To avoid this case, check that chan->desc is not null and channel is > disabled (transfer previously paused or terminated). > > Applied, thanks! [1/3] dmaengine: stm32-mdma: abort resume if no ongoing transfer commit: 81337b9a72dc58a5fa0ae8a042e8cb59f9bdec4a [2/3] dmaengine: stm32-mdma: use Link Address Register to compute residue commit: a4b306eb83579c07b63dc65cd5bae53b7b4019d0 [3/3] dmaengine: stm32-mdma: set in_flight_bytes in case CRQA flag is set commit: 584970421725b7805db84714b857851fdf7203a9 Best regards,
diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c index 0de234022c6d..cc6f4b00091f 100644 --- a/drivers/dma/stm32-mdma.c +++ b/drivers/dma/stm32-mdma.c @@ -1236,6 +1236,10 @@ static int stm32_mdma_resume(struct dma_chan *c) unsigned long flags; u32 status, reg; + /* Transfer can be terminated */ + if (!chan->desc || (stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id)) & STM32_MDMA_CCR_EN)) + return -EPERM; + hwdesc = chan->desc->node[chan->curr_hwdesc].hwdesc; spin_lock_irqsave(&chan->vchan.lock, flags);