memory: atmel-ebi: Fix SMC clock reference leak in atmel_ebi_probe()
PATCH 1/1 memory: atmel-ebi: Fix SMC clock reference leak in atmel_ebi_probe()
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")
Signed-off-by Wentao Liang <[email protected]>
--- drivers/memory/atmel-ebi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/memory/atmel-ebi.c +6 -1
@@ -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
Signature · 1 line
2.34.1