[PATCH] mmc: sdhci-dove: handle optional clock errors from devm_clk_get_optional_enabled()

From: Ziheng Wei

Date: Fri Dec 04 2026 - 04:12:45 EST


sdhci_dove_probe() assigns the return value of devm_clk_get_enabled()
to pltfm_host->clk without checking IS_ERR(). If the clock is missing or
fails to acquire, an ERR_PTR is stored in pltfm_host->clk while probe
still returns 0.

Because sdhci_dove_driver uses sdhci_pltfm_pmops, sdhci_pltfm_suspend()
and sdhci_pltfm_resume() later pass pltfm_host->clk directly to
clk_disable_unprepare() and clk_prepare_enable(), which only guard against
NULL and dereference clk->core on an ERR_PTR.

Use devm_clk_get_optional_enabled() so an absent clock resolves to NULL
(safely ignored by clk helpers) and return PTR_ERR() on genuine errors.

Found by LLM-assisted static analysis. Compile-tested on x86_64.

Fixes: 6a4a34a413d8 ("mmc: sdhci-dove: remove the unneeded error check")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ziheng Wei <zihengw03@xxxxxxx>
---
drivers/mmc/host/sdhci-dove.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index dbfaee4a5..76fb2b5a3 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -75,7 +75,9 @@ static int sdhci_dove_probe(struct platform_device *pdev)
return PTR_ERR(host);

pltfm_host = sdhci_priv(host);
- pltfm_host->clk = devm_clk_get_enabled(&pdev->dev, NULL);
+ pltfm_host->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
+ if (IS_ERR(pltfm_host->clk))
+ return PTR_ERR(pltfm_host->clk);

ret = mmc_of_parse(host->mmc);
if (ret)

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0