Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: stm32-timers: depopulate child devices on populate failure
@ 2026-06-15  6:30 Pengpeng Hou
  2026-07-01 21:42 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-15  6:30 UTC (permalink / raw)
  To: Fabrice Gasnier, Lee Jones, Maxime Coquelin, Alexandre Torgue,
	linux-stm32, linux-arm-kernel, linux-kernel
  Cc: pengpeng

stm32_timers_probe() releases the timer DMA resources when
of_platform_populate() fails, but it does not depopulate any child
devices that were created before the failure.

The remove path explicitly depopulates child devices before releasing
DMA resources to avoid races with children using DMA.  Apply the same
ordering on the populate failure path.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/mfd/stm32-timers.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c
index b3dbc02aaf79..1f0aecae83a5 100644
--- a/drivers/mfd/stm32-timers.c
+++ b/drivers/mfd/stm32-timers.c
@@ -329,8 +329,10 @@ static int stm32_timers_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, ddata);
 
 	ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
-	if (ret)
+	if (ret) {
+		of_platform_depopulate(&pdev->dev);
 		stm32_timers_dma_remove(dev, ddata);
+	}
 
 	return ret;
 }
-- 
2.50.1 (Apple Git-155)



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

* Re: [PATCH] mfd: stm32-timers: depopulate child devices on populate failure
  2026-06-15  6:30 [PATCH] mfd: stm32-timers: depopulate child devices on populate failure Pengpeng Hou
@ 2026-07-01 21:42 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2026-07-01 21:42 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Fabrice Gasnier, Maxime Coquelin, Alexandre Torgue, linux-stm32,
	linux-arm-kernel, linux-kernel

On Mon, 15 Jun 2026, Pengpeng Hou wrote:

> stm32_timers_probe() releases the timer DMA resources when
> of_platform_populate() fails, but it does not depopulate any child
> devices that were created before the failure.
> 
> The remove path explicitly depopulates child devices before releasing
> DMA resources to avoid races with children using DMA.  Apply the same
> ordering on the populate failure path.
> 
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
>  drivers/mfd/stm32-timers.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c
> index b3dbc02aaf79..1f0aecae83a5 100644
> --- a/drivers/mfd/stm32-timers.c
> +++ b/drivers/mfd/stm32-timers.c
> @@ -329,8 +329,10 @@ static int stm32_timers_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, ddata);
>  
>  	ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
> -	if (ret)
> +	if (ret) {
> +		of_platform_depopulate(&pdev->dev);

It's strange to see an un-winder inside the error handling of its
original call.  We're used to seeing them called only on success during
a subsequent step.

Wouldn't devm_of_platform_populate() be better here instead?

>  		stm32_timers_dma_remove(dev, ddata);
> +	}
>  
>  	return ret;
>  }
> -- 
> 2.50.1 (Apple Git-155)
> 

-- 
Lee Jones


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

end of thread, other threads:[~2026-07-01 21:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15  6:30 [PATCH] mfd: stm32-timers: depopulate child devices on populate failure Pengpeng Hou
2026-07-01 21:42 ` Lee Jones

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