[PATCH] mmc: sdhci-of-arasan: Unregister all clock providers
From: Wentao Liang
Date: Tue Nov 03 2026 - 05:17:07 EST
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@xxxxxxxxxxxxxxx
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
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