[PATCH 05/10] dmaengine: amlogic: Destroy free_wq after devres DMA device unregistration
From: Lee Jones
Date: Wed Nov 11 2026 - 17:00:04 EST
aml_dma_probe() registers the DMA device with
dmaenginem_async_device_register(), so dma_async_device_unregister() is
deferred until devres release after aml_dma_remove() returns. However,
aml_dma_remove() destroys aml_dma->free_wq directly, causing
aml_dma_free_desc() to queue work onto a destroyed workqueue when
channels and descriptors are released during devres teardown, and early
error returns in aml_dma_probe() also leak aml_dma->free_wq.
Allocate aml_dma->free_wq with devm_alloc_ordered_workqueue() so it is
destroyed on probe failure and after dmaenginem_async_device_register()
unwinds on removal.
Fixes: b84b5197e344 ("dmaengine: amlogic: Add general DMA driver for A9")
Closes: https://sashiko.dev/#/bug/linux-c216084a-f89a-48d5-bdea-584522d1bdda
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/dma/amlogic-dma.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/dma/amlogic-dma.c b/drivers/dma/amlogic-dma.c
index 684121d13fca..791bd82743d3 100644
--- a/drivers/dma/amlogic-dma.c
+++ b/drivers/dma/amlogic-dma.c
@@ -620,7 +620,7 @@ static int aml_dma_probe(struct platform_device *pdev)
if (!aml_dma)
return -ENOMEM;
- aml_dma->free_wq = alloc_ordered_workqueue("aml_dma_free", 0);
+ aml_dma->free_wq = devm_alloc_ordered_workqueue(&pdev->dev, "aml_dma_free", 0);
if (!aml_dma->free_wq)
return -ENOMEM;
@@ -712,7 +712,6 @@ static void aml_dma_remove(struct platform_device *pdev)
if (aml_chan)
tasklet_kill(&aml_chan->vchan.task);
}
- destroy_workqueue(aml_dma->free_wq);
}
static const struct of_device_id aml_dma_ids[] = {
--
2.56.0.567.gdb80ae8cd5-goog