[PATCH] memory: atmel-ebi: unwind SMC clock on probe failures
Pengpeng Hou
pengpeng at iscas.ac.cn
Tue Jun 16 08:17:57 PDT 2026
atmel_ebi_probe() obtains the SMC clock with of_clk_get() and enables it
before several later validation and child setup steps. Those later
failures currently return directly, leaving the non-managed SMC clock
enabled and referenced.
Route the post-enable failures through common cleanup labels, put the SMC
clock on enable failure, and depopulate any partially created children if
the final child population fails.
Signed-off-by: Pengpeng Hou <pengpeng at iscas.ac.cn>
---
drivers/memory/atmel-ebi.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
index 1e8e8aba2542..f331eed362c5 100644
--- a/drivers/memory/atmel-ebi.c
+++ b/drivers/memory/atmel-ebi.c
@@ -562,7 +562,7 @@ static int atmel_ebi_probe(struct platform_device *pdev)
}
ret = clk_prepare_enable(ebi->smc.clk);
if (ret)
- return ret;
+ goto err_put_smc_clk;
/*
* The sama5d3 does not provide an EBICSA register and thus does need
@@ -572,14 +572,16 @@ static int atmel_ebi_probe(struct platform_device *pdev)
ebi->regmap =
syscon_regmap_lookup_by_phandle(np,
ebi->caps->regmap_name);
- if (IS_ERR(ebi->regmap))
- return PTR_ERR(ebi->regmap);
+ if (IS_ERR(ebi->regmap)) {
+ ret = PTR_ERR(ebi->regmap);
+ goto err_disable_smc_clk;
+ }
}
ret = of_property_read_u32(np, "#address-cells", &val);
if (ret) {
dev_err(dev, "missing #address-cells property\n");
- return ret;
+ goto err_disable_smc_clk;
}
reg_cells = val;
@@ -587,7 +589,7 @@ static int atmel_ebi_probe(struct platform_device *pdev)
ret = of_property_read_u32(np, "#size-cells", &val);
if (ret) {
dev_err(dev, "missing #address-cells property\n");
- return ret;
+ goto err_disable_smc_clk;
}
reg_cells += val;
@@ -603,11 +605,23 @@ static int atmel_ebi_probe(struct platform_device *pdev)
ret = atmel_ebi_dev_disable(ebi, child);
if (ret)
- return ret;
+ goto err_disable_smc_clk;
}
}
- return of_platform_populate(np, NULL, NULL, dev);
+ ret = of_platform_populate(np, NULL, NULL, dev);
+ if (ret) {
+ of_platform_depopulate(dev);
+ goto err_disable_smc_clk;
+ }
+
+ return 0;
+
+err_disable_smc_clk:
+ clk_disable_unprepare(ebi->smc.clk);
+err_put_smc_clk:
+ clk_put(ebi->smc.clk);
+ return ret;
}
static __maybe_unused int atmel_ebi_resume(struct device *dev)
--
2.43.0
More information about the linux-arm-kernel
mailing list