[PATCH] mfd: stm32-timers: depopulate child devices on populate failure

Lee Jones lee at kernel.org
Wed Jul 1 14:42:50 PDT 2026


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 at 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



More information about the linux-arm-kernel mailing list