Re: [PATCH] crypto: caam: depopulate job rings on populate failure

From: Herbert Xu

Date: Fri Jul 03 2026 - 05:14:53 EST


On Tue, Jun 16, 2026 at 08:52:39AM +0800, Pengpeng Hou wrote:
> devm_of_platform_populate() only registers its automatic cleanup action
> after child population succeeds. If CAAM job-ring population fails after
> creating some job-ring devices, the probe error path reports the error
> but leaves the partial children registered.
>
> Explicitly depopulate the job-ring children on the populate failure path.
>
> Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
> ---
> drivers/crypto/caam/ctrl.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
> index 320be5d77737..716c57b9f89b 100644
> --- a/drivers/crypto/caam/ctrl.c
> +++ b/drivers/crypto/caam/ctrl.c
> @@ -1150,8 +1150,10 @@ static int caam_probe(struct platform_device *pdev)
> ctrlpriv->total_jobrs, ctrlpriv->qi_present);
>
> ret = devm_of_platform_populate(dev);
> - if (ret)
> + if (ret) {
> dev_err(dev, "JR platform devices creation error\n");
> + of_platform_depopulate(dev);
> + }

This seems counter-intuitive. Why is this necessary and if it is,
why isn't this just a bug in devm_of_platform_populate?

Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt