* [PATCH] memory: atmel-ebi: release the SMC clock on probe failure
@ 2026-11-03 9:46 Wentao Liang
2026-11-03 10:20 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-11-03 9:46 UTC (permalink / raw)
To: Krzysztof Kozlowski, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: linux-kernel, linux-arm-kernel, Wentao Liang, stable
of_clk_get() returns a consumer reference and clk_prepare_enable()
enables the SMC clock, but the probe error paths after that point
return without dropping either. If the regmap lookup, the
address/size-cells parsing, disabling a child device or
of_platform_populate() fails, the clock stays enabled and its
reference is leaked.
Unwind both on these error paths. A successful probe still keeps the
clock enabled for the lifetime of the controller, as before.
Fixes: 87108dc78eb8 ("memory: atmel-ebi: Enable the SMC clock if specified")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/memory/atmel-ebi.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
index 1e8e8aba2542..f412e53f4199 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_clk_put;
/*
* 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_clk_disable;
+ }
}
ret = of_property_read_u32(np, "#address-cells", &val);
if (ret) {
dev_err(dev, "missing #address-cells property\n");
- return ret;
+ goto err_clk_disable;
}
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_clk_disable;
}
reg_cells += val;
@@ -603,11 +605,22 @@ static int atmel_ebi_probe(struct platform_device *pdev)
ret = atmel_ebi_dev_disable(ebi, child);
if (ret)
- return ret;
+ goto err_clk_disable;
}
}
- return of_platform_populate(np, NULL, NULL, dev);
+ ret = of_platform_populate(np, NULL, NULL, dev);
+ if (ret)
+ goto err_clk_disable;
+
+ return 0;
+
+err_clk_disable:
+ clk_disable_unprepare(ebi->smc.clk);
+err_clk_put:
+ clk_put(ebi->smc.clk);
+
+ return ret;
}
static __maybe_unused int atmel_ebi_resume(struct device *dev)
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] memory: atmel-ebi: release the SMC clock on probe failure
2026-11-03 9:46 [PATCH] memory: atmel-ebi: release the SMC clock on probe failure Wentao Liang
@ 2026-11-03 10:20 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-03 10:20 UTC (permalink / raw)
To: Wentao Liang, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: linux-kernel, linux-arm-kernel, stable
On 03/11/2026 10:46, Wentao Liang wrote:
> of_clk_get() returns a consumer reference and clk_prepare_enable()
> enables the SMC clock, but the probe error paths after that point
> return without dropping either. If the regmap lookup, the
> address/size-cells parsing, disabling a child device or
> of_platform_populate() fails, the clock stays enabled and its
> reference is leaked.
>
> Unwind both on these error paths. A successful probe still keeps the
> clock enabled for the lifetime of the controller, as before.
>
> Fixes: 87108dc78eb8 ("memory: atmel-ebi: Enable the SMC clock if specified")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
I do not take patches from you.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-03 10:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 9:46 [PATCH] memory: atmel-ebi: release the SMC clock on probe failure Wentao Liang
2026-11-03 10:20 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®