summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAmelie Delaunay <amelie.delaunay@foss.st.com>2023-10-04 19:35:28 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-25 12:54:14 +0300
commit2d30692c6c9442b1a8cd5405486d218836a385a6 (patch)
tree77d42b36b3de55cc1f15f5cd8fca2546307c21a6 /drivers
parentd346a2ef6b1ebb77d740890cfaf8478c5b286380 (diff)
downloadlinux-2d30692c6c9442b1a8cd5405486d218836a385a6.tar.xz
dmaengine: stm32-mdma: abort resume if no ongoing transfer
commit 81337b9a72dc58a5fa0ae8a042e8cb59f9bdec4a upstream. 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 Link: https://lore.kernel.org/r/20231004163531.2864160-1-amelie.delaunay@foss.st.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dma/stm32-mdma.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c
index 9d54746c422c..3e57176ca0ca 100644
--- a/drivers/dma/stm32-mdma.c
+++ b/drivers/dma/stm32-mdma.c
@@ -1206,6 +1206,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);