[PATCH] mmc: sdhci-s3c: check clk_prepare_enable return in probe

Jiawen Liu posted 1 patch 1 month, 1 week ago
[PATCH] mmc: sdhci-s3c: check clk_prepare_enable return in probe
Posted by Jiawen Liu 1 month, 1 week ago
sdhci_s3c_probe() ignores the return value of
clk_prepare_enable(sc->clk_io). If this call fails, the clock is not
enabled, but the driver continues and later calls
clk_disable_unprepare() on it, leading to an unbalanced clock
disable/unprepare.

Fix this by checking the return value and propagating the error,
cleaning up only resources acquired before the failed enable.

Signed-off-by: jiawen <1298662399@qq.com>
---
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -534,7 +534,11 @@
 	}
 
 	/* enable the local io clock and keep it running for the moment. */
-	clk_prepare_enable(sc->clk_io);
+	ret = clk_prepare_enable(sc->clk_io);
+	if (ret) {
+		dev_err(dev, "failed to enable io clock\n");
+		return ret;
+	}
 
 	for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
 		char name[14];
Re: [PATCH] mmc: sdhci-s3c: check clk_prepare_enable return in probe
Posted by Adrian Hunter 1 month ago
On 18/08/2026 16:07, Jiawen Liu wrote:
> sdhci_s3c_probe() ignores the return value of
> clk_prepare_enable(sc->clk_io). If this call fails, the clock is not
> enabled, but the driver continues and later calls
> clk_disable_unprepare() on it, leading to an unbalanced clock
> disable/unprepare.
> 
> Fix this by checking the return value and propagating the error,
> cleaning up only resources acquired before the failed enable.
> 
> Signed-off-by: jiawen <1298662399@qq.com>

scripts/checkpatch.pl says:

WARNING: From:/Signed-off-by: email name mismatch: 'From: Jiawen Liu <1298662399@qq.com>' != 'Signed-off-by: jiawen <1298662399@qq.com>'

Please adjust that.

> ---
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -534,7 +534,11 @@
>  	}
>  
>  	/* enable the local io clock and keep it running for the moment. */
> -	clk_prepare_enable(sc->clk_io);
> +	ret = clk_prepare_enable(sc->clk_io);
> +	if (ret) {
> +		dev_err(dev, "failed to enable io clock\n");
> +		return ret;
> +	}
>  
>  	for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
>  		char name[14];
>
Re: [PATCH] mmc: sdhci-s3c: check clk_prepare_enable return in probe
Posted by Markus Elfring 1 month, 1 week ago
…
> Fix this by checking the return value and propagating the error,
> cleaning up only resources acquired before the failed enable.

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?

See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v7.2#n34
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.2#n145
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.2#n792

Regards,
Markus