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

Lee Jones lee at kernel.org
Fri Jul 3 00:47:01 PDT 2026


On Fri, 03 Jul 2026, Pengpeng Hou wrote:

> Hi Lee,
> 
> Thanks for taking a look.
> 
> I checked devm_of_platform_populate(), but I don't think it covers this
> particular failure path on its own.
> 
> devm_of_platform_populate() only installs the devres cleanup after
> of_platform_populate() has returned success.  If of_platform_populate()
> returns an error after creating some earlier children, the helper just
> frees its devres record and those partial children are not depopulated.
> 
> For stm32-timers, I think we still need the explicit ordering used by
> remove: depopulate children before stm32_timers_dma_remove().  The child
> drivers get the parent drvdata, and the PWM child can call the parent
> stm32_timers_dma_burst_read() helper, so releasing the parent DMA
> channels while partially-created children remain would keep the same
> ordering problem the remove path avoids.
> 
> I agree the inline unwind is not the clearest form.  I can send a v2
> using a normal goto unwind label and a short comment explaining the
> partial-populate case, unless you prefer a different shape.

I'm not concerned about where in the file the call sits.  Calls like
this that fail usually do so cleanly.  I think this deserves a wider
piece of work that ensures that of_platform_populate() doesn't leave
dangling resources when it fails.

Also, why doesn't every call to of_platform_populate() have this?

-- 
Lee Jones



More information about the linux-arm-kernel mailing list