Skip to contentSkip to conversation

crypto: caam: depopulate job rings on populate failure

PATCH In review Pengpeng Hou 2 participants 2 messages Jun 16 – Jul 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: caam: depopulate job rings on populate failure

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.

---
 drivers/crypto/caam/ctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/caam/ctrl.c +3 -1
index 320be5d77737..716c57b9f89b 100644
@@ -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);
+	}
 
 	return ret;
 }
Signature · 1 line
2.50.1 (Apple Git-155)
maintainer
#1 lore raw
Quoted 17 lines · Pengpeng Hou

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.

---
 drivers/crypto/caam/ctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/caam/ctrl.c +0 -0
index 320be5d77737..716c57b9f89b 100644

drivers/crypto/caam/ctrl.c static int caam_probe(struct platform_device *pdev) · line 1156

Quoted 8 lines
drivers/crypto/caam/ctrl.c +3 -1
@@ -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,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt