DMA Engine development
 help / color / mirror / Atom feed
* [PATCH 0/2] dmaengine: ti: Withdraw DMA providers on removal
@ 2026-11-28 11:02 Tian Xuechen
  2026-11-28 11:02 ` [PATCH 1/2] dmaengine: ti: k3-udma: Withdraw the " Tian Xuechen
  2026-11-28 11:02 ` [PATCH 2/2] dmaengine: ti-dma-crossbar: Unregister the DMA router " Tian Xuechen
  0 siblings, 2 replies; 4+ messages in thread
From: Tian Xuechen @ 2026-11-28 11:02 UTC (permalink / raw)
  To: vigneshr, vkoul, peter.ujfalusi, grygorii.strashko
  Cc: Frank.Li, dmaengine, liguangshuo

From: Tian Xuechen <202300460064@mail.sdu.edu.cn>

Pair provider registration with removal for the K3 UDMA controller and
the TI DMA crossbar.

Tian Xuechen (2):
  dmaengine: ti: k3-udma: Withdraw the DMA providers on removal
  dmaengine: ti-dma-crossbar: Unregister the DMA router on removal

base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] dmaengine: ti: k3-udma: Withdraw the DMA providers on removal
  2026-11-28 11:02 [PATCH 0/2] dmaengine: ti: Withdraw DMA providers on removal Tian Xuechen
@ 2026-11-28 11:02 ` Tian Xuechen
  2026-11-28 11:14   ` sashiko-bot
  2026-11-28 11:02 ` [PATCH 2/2] dmaengine: ti-dma-crossbar: Unregister the DMA router " Tian Xuechen
  1 sibling, 1 reply; 4+ messages in thread
From: Tian Xuechen @ 2026-11-28 11:02 UTC (permalink / raw)
  To: vigneshr, vkoul, peter.ujfalusi, grygorii.strashko
  Cc: Frank.Li, dmaengine, liguangshuo

From: Tian Xuechen <202300460064@mail.sdu.edu.cn>

The OF controller and DMA engine remain registered when the driver
is unloaded. Manage the two registrations so they are undone in
reverse order before devres releases the UDMA device.

This issue was found by our static analysis tool under development.

Fixes: 25dcb5dd7b7c ("dmaengine: ti: New driver for K3 UDMA")
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
 drivers/dma/ti/k3-udma.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 75bd1977fb42..1349585711b8 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -5619,7 +5619,7 @@ static int udma_probe(struct platform_device *pdev)
 	/* Configure the copy_align to the maximum burst size the device supports */
 	ud->ddev.copy_align = udma_get_copy_align(ud);
 
-	ret = dma_async_device_register(&ud->ddev);
+	ret = dmaenginem_async_device_register(&ud->ddev);
 	if (ret) {
 		dev_err(dev, "failed to register slave DMA engine: %d\n", ret);
 		return ret;
@@ -5627,11 +5627,9 @@ static int udma_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ud);
 
-	ret = of_dma_controller_register(dev->of_node, udma_of_xlate, ud);
-	if (ret) {
+	ret = devm_of_dma_controller_register(dev, dev->of_node, udma_of_xlate, ud);
+	if (ret)
 		dev_err(dev, "failed to register of_dma controller\n");
-		dma_async_device_unregister(&ud->ddev);
-	}
 
 	return ret;
 }

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] dmaengine: ti-dma-crossbar: Unregister the DMA router on removal
  2026-11-28 11:02 [PATCH 0/2] dmaengine: ti: Withdraw DMA providers on removal Tian Xuechen
  2026-11-28 11:02 ` [PATCH 1/2] dmaengine: ti: k3-udma: Withdraw the " Tian Xuechen
@ 2026-11-28 11:02 ` Tian Xuechen
  1 sibling, 0 replies; 4+ messages in thread
From: Tian Xuechen @ 2026-11-28 11:02 UTC (permalink / raw)
  To: vigneshr, vkoul, peter.ujfalusi, grygorii.strashko
  Cc: Frank.Li, dmaengine, liguangshuo

From: Tian Xuechen <202300460064@mail.sdu.edu.cn>

The DMA router remains in the OF registry after its device-managed
data is released. Remove the routing entry when the device is
unbound.

This issue was found by our static analysis tool under development.

Fixes: a074ae38f859 ("dmaengine: Add driver for TI DMA crossbar on DRA7x")
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
 drivers/dma/ti/dma-crossbar.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/dma/ti/dma-crossbar.c b/drivers/dma/ti/dma-crossbar.c
index b1e66792e7de..a35a8a60c300 100644
--- a/drivers/dma/ti/dma-crossbar.c
+++ b/drivers/dma/ti/dma-crossbar.c
@@ -467,12 +467,18 @@ static int ti_dma_xbar_probe(struct platform_device *pdev)
 	return ret;
 }
 
+static void ti_dma_xbar_remove(struct platform_device *pdev)
+{
+	of_dma_router_free(pdev->dev.of_node);
+}
+
 static struct platform_driver ti_dma_xbar_driver = {
 	.driver = {
 		.name = "ti-dma-crossbar",
 		.of_match_table = ti_dma_xbar_match,
 	},
 	.probe	= ti_dma_xbar_probe,
+	.remove	= ti_dma_xbar_remove,
 };
 
 static int omap_dmaxbar_init(void)

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] dmaengine: ti: k3-udma: Withdraw the DMA providers on removal
  2026-11-28 11:02 ` [PATCH 1/2] dmaengine: ti: k3-udma: Withdraw the " Tian Xuechen
@ 2026-11-28 11:14   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-28 11:14 UTC (permalink / raw)
  To: Tian Xuechen; +Cc: dmaengine, vkoul, Frank.Li

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] dmaengine: ti: k3-udma: missing workqueue cancellation in
  udma_driver [1]
--

commit c1fb8f8e2baaa454720ded377f244f55b66ebe93
Author: Tian Xuechen <202300460064@mail.sdu.edu.cn>

dmaengine: ti: k3-udma: Withdraw the DMA providers on removal

This commit switches the DMA device and OF DMA controller registrations in
udma_probe() to devres-managed helpers so they are unregistered on driver
removal.

> diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
> index 75bd1977fb423..1349585711b80 100644
> --- a/drivers/dma/ti/k3-udma.c
> +++ b/drivers/dma/ti/k3-udma.c
> @@ -5619,7 +5619,7 @@ static int udma_probe(struct platform_device *pdev)
>  	/* Configure the copy_align to the maximum burst size the device supports */
>  	ud->ddev.copy_align = udma_get_copy_align(ud);
>  
> -	ret = dma_async_device_register(&ud->ddev);
> +	ret = dmaenginem_async_device_register(&ud->ddev);
>  	if (ret) {
>  		dev_err(dev, "failed to register slave DMA engine: %d\n", ret);
>  		return ret;
> @@ -5627,11 +5627,9 @@ static int udma_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, ud);
>  
> -	ret = of_dma_controller_register(dev->of_node, udma_of_xlate, ud);
> -	if (ret) {
> +	ret = devm_of_dma_controller_register(dev, dev->of_node, udma_of_xlate, ud);
> +	if (ret)
>  		dev_err(dev, "failed to register of_dma controller\n");
> -		dma_async_device_unregister(&ud->ddev);
> -	}
>  
>  	return ret;
>  }

[Severity: Critical]
This problem wasn't introduced by this patch, but can unloading the module
leave ud->purge_work or uc->tx_drain.work pending after devres frees
struct udma_dev [1]?

udma_probe() allocates ud and its channels with devm_kzalloc() and
initializes ud->purge_work (udma_purge_desc_work()) and uc->tx_drain.work
(udma_check_tx_completion()), while udma_driver has no .remove callback
and registers no devm action to cancel them.  If the module is unloaded
while either work item is queued, the worker can run after devres frees ud
and cause a use-after-free.

[1] https://sashiko.dev/#/bug/linux-ab017a54-94b4-4224-b85f-161bcb4066df

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128110224.875369-1-202300460064@mail.sdu.edu.cn?part=1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-28 11:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 11:02 [PATCH 0/2] dmaengine: ti: Withdraw DMA providers on removal Tian Xuechen
2026-11-28 11:02 ` [PATCH 1/2] dmaengine: ti: k3-udma: Withdraw the " Tian Xuechen
2026-11-28 11:14   ` sashiko-bot
2026-11-28 11:02 ` [PATCH 2/2] dmaengine: ti-dma-crossbar: Unregister the DMA router " Tian Xuechen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox