soc: qcom: geni: depopulate children on populate failure
Subsystems (2)
PATCH 1/1 soc: qcom: geni: depopulate children on populate failure
devm_of_platform_populate() installs its devres cleanup action only after of_platform_populate() succeeds. If child population fails after creating some GENI children, those partial children are not automatically removed by devres because the action was never added.
Depopulate the children explicitly when devm_of_platform_populate() returns an error.
--- drivers/soc/qcom/qcom-geni-se.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/soc/qcom/qcom-geni-se.c +5 -1
@@ -1406,7 +1406,11 @@ static int geni_se_probe(struct platform_device *pdev)dev_set_drvdata (dev, wrapper);dev_dbg (dev,"GENI SE Driver probed\n" ); -return devm_of_platform_populate (dev); + ret =devm_of_platform_populate (dev); +if (ret) +of_platform_depopulate (dev); + +return ret; }static const char *const qup_clks[] = {
Signature · 1 line
2.50.1 (Apple Git-155)
Bjorn Andersson
maintainerQuoted 2 lines · Pengpeng Hou
devm_of_platform_populate()installs its devres cleanup action only afterof_platform_populate()succeeds.
And if it fails it runs the cleanup function.
Quoted 3 lines
If child population fails after creating
some GENI children, those partial children are not automatically removed by devres because the action was never added.
Did you test this?
Quoted 4 lines
Depopulate the children explicitly when
devm_of_platform_populate()returns an error.
For now I'll consider this patch to be wrong, please fix devm_of_platform_populate() if your analysis is correct.
Thanks,
Bjorn
Quoted 25 lines
Signed-off-by Pengpeng Hou <[email protected]>--- drivers/soc/qcom/qcom-geni-se.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/soc/qcom/qcom-geni-se.c +5
-1@@ -1406,7 +1406,11 @@ static int geni_se_probe(struct platform_device *pdev)dev_set_drvdata (dev, wrapper);dev_dbg (dev,"GENI SE Driver probed\n" ); -return devm_of_platform_populate (dev); + ret =devm_of_platform_populate (dev); +if (ret) +of_platform_depopulate (dev); + +return ret; }static const char *const qup_clks[] = {Signature · 1 line
2.50.1 (Apple Git-155)
Hi Bjorn,
Understood. I misread devm_of_platform_populate()'s failure and cleanup semantics; the GENI driver does not need an additional depopulate call. I will drop the patch.
Thanks,
Pengpeng