Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Wentao Liang <vulab@iscas.ac.cn>
To: alexandre.belloni@bootlin.com
Cc: bbrezillon@kernel.org, claudiu.beznea@tuxon.dev, krzk@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, nicolas.ferre@microchip.com,
	Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
Subject: [PATCH] memory: atmel-ebi: Fix SMC clock reference leak in atmel_ebi_probe()
Date: Thu, 17 Sep 2026 10:16:23 +0000	[thread overview]
Message-ID: <20260917101623.2146392-1-vulab@iscas.ac.cn> (raw)

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@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 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



                 reply	other threads:[~2026-09-17 10:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260917101623.2146392-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bbrezillon@kernel.org \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox