[PATCH] memory: atmel-ebi: Fix SMC clock reference leak in atmel_ebi_probe()

From: Wentao Liang

Date: Thu Sep 17 2026 - 06:31:15 EST


atmel_ebi_probe() takes a reference to the SMC clock with
of_clk_get(), stores it in ebi->smc.clk and enables it, but the
reference is never released: the driver has no remove callback and
none of the error paths after the clock has been enabled call
clk_put(), so the reference leaks on the success path and on every
error path.

Drop the reference with clk_put() once the clock has been prepared
and enabled. The clock itself stays enabled, as the driver needs it
to keep the SMC registers accessible.

Fixes: 87108dc78eb8 ("memory: atmel-ebi: Enable the SMC clock if specified")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/memory/atmel-ebi.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
index 8db970da9af9..cd138a3b793c 100644
--- a/drivers/memory/atmel-ebi.c
+++ b/drivers/memory/atmel-ebi.c
@@ -561,8 +561,13 @@ static int atmel_ebi_probe(struct platform_device *pdev)
ebi->smc.clk = NULL;
}
ret = clk_prepare_enable(ebi->smc.clk);
- if (ret)
+ if (ret) {
+ clk_put(ebi->smc.clk);
return ret;
+ }
+
+ /* The clock stays enabled; drop the unneeded consumer reference. */
+ clk_put(ebi->smc.clk);

/*
* The sama5d3 does not provide an EBICSA register and thus does need
--
2.34.1