mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-of-arasan: Unregister all clock providers
@ 2026-11-03 10:05 Wentao Liang
  2026-11-03 10:26 ` Krzysztof Kozlowski
  2026-11-04 18:23 ` Adrian Hunter
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-03 10:05 UTC (permalink / raw)
  To: Michal Simek, Adrian Hunter, Ulf Hansson
  Cc: linux-arm-kernel, linux-mmc, linux-kernel, Wentao Liang, stable

When #clock-cells is non-zero, sdhci_arasan_register_sdclk() registers
two clock providers for the same device node: one for the card clock and
one for the sample clock.  of_clk_add_provider() takes a reference to
the device node for each registration, but the unregister helper only
calls of_clk_del_provider() once.  The second device node reference is
therefore leaked and the sample clock provider remains registered after
the driver has been unbound.

Drop one provider for every clock that was registered.

Fixes: 07a14d1df454 ("mmc: sdhci-of-arasan: Add sampling clock for a phy to use")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/mmc/host/sdhci-of-arasan.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index 0ee22923ad56..dccd2980fdd6 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -1648,11 +1648,20 @@ sdhci_arasan_register_sampleclk(struct sdhci_arasan_data *sdhci_arasan,
 static void sdhci_arasan_unregister_sdclk(struct device *dev)
 {
 	struct device_node *np = dev->of_node;
+	u32 num_clks = 0;
 
-	if (!of_property_present(np, "#clock-cells"))
+	if (of_property_read_u32(np, "#clock-cells", &num_clks) < 0)
 		return;
 
-	of_clk_del_provider(dev->of_node);
+	of_clk_del_provider(np);
+
+	/*
+	 * sdhci_arasan_register_sdclk() registers a second provider for the
+	 * sample clock when #clock-cells is non-zero, and each provider holds
+	 * its own reference to the device node.
+	 */
+	if (num_clks)
+		of_clk_del_provider(np);
 }
 
 /**
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-04 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 10:05 [PATCH] mmc: sdhci-of-arasan: Unregister all clock providers Wentao Liang
2026-11-03 10:26 ` Krzysztof Kozlowski
2026-11-04 18:23 ` Adrian Hunter

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®