Skip to contentSkip to conversation

mmc: sdhci: Fix a potential uninitialized variable

PATCH In review Dan Carpenter 2 participants 2 messages Jul 14, 2020 – Aug 5, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci: Fix a potential uninitialized variable

Smatch complains that "ret" can be used without being initialized.

drivers/mmc/host/sdhci.c
4383 if (!IS_ERR(mmc->supply.vqmmc)) {

  4384                  if (enable_vqmmc) {
                            ^^^^^^^^^^^^
  4385                          ret = regulator_enable(mmc->supply.vqmmc);
                                ^^^^^

4386 host->sdhci_core_to_disable_vqmmc = !ret;
4387 }

"ret" is only initialized when "enable_vqmmc" is true.

Fixes b13099a4dea6 ("mmc: sdhci: Fix potential null pointer access while accessing vqmmc")
---
 drivers/mmc/host/sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +1 -1
index 8db06da55602..3ad394b40eb1 100644
@@ -4104,7 +4104,7 @@ int sdhci_setup_host(struct sdhci_host *host)
 	unsigned int ocr_avail;
 	unsigned int override_timeout_clk;
 	u32 max_clk;
-	int ret;
+	int ret = 0;
 	bool enable_vqmmc = false;
 
 	WARN_ON(host = NULL);
Signature · 1 line
2.27.0
#1 lore raw
Quoted 9 lines · Dan Carpenter

Smatch complains that "ret" can be used without being initialized.

drivers/mmc/host/sdhci.c
4383 if (!IS_ERR(mmc->supply.vqmmc)) {

  4384                  if (enable_vqmmc) {
                            ^^^^^^^^^^^^
  4385                          ret = regulator_enable(mmc->supply.vqmmc);
                                ^^^^^
Quoted 7 lines

4386 host->sdhci_core_to_disable_vqmmc = !ret;
4387 }

"ret" is only initialized when "enable_vqmmc" is true.

Fixes b13099a4dea6 ("mmc: sdhci: Fix potential null pointer access while accessing vqmmc")

Applied for next (a while ago), thanks!
Kind regards
Uffe

Quoted 20 lines
---
 drivers/mmc/host/sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +1 -2
index 8db06da55602..3ad394b40eb1 100644
@@ -4104,7 +4104,7 @@ int sdhci_setup_host(struct sdhci_host *host)
        unsigned int ocr_avail;
        unsigned int override_timeout_clk;
        u32 max_clk;
-       int ret;
+       int ret = 0;
        bool enable_vqmmc = false;
 
        WARN_ON(host = NULL);
--

2.27.0