Skip to contentSkip to conversation

mmc: sdhci: Fix potential null pointer access while accessing vqmmc

PATCH In review Veerabhadrarao Badiganti 2 participants 2 messages Jul 9, 2020 – Jul 10, 2020

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

PATCH 1/1 mmc: sdhci: Fix potential null pointer access while accessing vqmmc

Don't access vqmmc regulator handler, if it's already invalidated.

Fixes f870b6d480d3 (mmc: sdhci: Allow platform controlled voltage switching)
---
 drivers/mmc/host/sdhci.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/mmc/host/sdhci.c +7 -5
index e6275c2202b0..d3b62fc5c661 100644
@@ -4383,11 +4383,6 @@ int sdhci_setup_host(struct sdhci_host *host)
 	if (!IS_ERR(mmc->supply.vqmmc)) {
 		if (enable_vqmmc) {
 			ret = regulator_enable(mmc->supply.vqmmc);
-			if (ret) {
-				pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
-					mmc_hostname(mmc), ret);
-				mmc->supply.vqmmc = ERR_PTR(-EINVAL);
-			}
 			host->sdhci_core_to_disable_vqmmc = !ret;
 		}
 
@@ -4402,6 +4397,13 @@ int sdhci_setup_host(struct sdhci_host *host)
 		if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 2700000,
 						    3600000))
 			host->flags &= ~SDHCI_SIGNALING_330;
+
+		if (ret) {
+			pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
+				mmc_hostname(mmc), ret);
+			mmc->supply.vqmmc = ERR_PTR(-EINVAL);
+		}
+
 	}
 
 	if (host->quirks2 & SDHCI_QUIRK2_NO_1_8_V) {
Signature · 1 line
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#1 lore raw
Quoted 6 lines · Veerabhadrarao Badiganti

Don't access vqmmc regulator handler, if it's already invalidated.

Fixes f870b6d480d3 (mmc: sdhci: Allow platform controlled voltage switching)

Applied for next, thanks!

Kind regards
Uffe

Quoted 37 lines
---
 drivers/mmc/host/sdhci.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/mmc/host/sdhci.c +7 -6
index e6275c2202b0..d3b62fc5c661 100644
@@ -4383,11 +4383,6 @@ int sdhci_setup_host(struct sdhci_host *host)
        if (!IS_ERR(mmc->supply.vqmmc)) {
                if (enable_vqmmc) {
                        ret = regulator_enable(mmc->supply.vqmmc);
-                       if (ret) {
-                               pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
-                                       mmc_hostname(mmc), ret);
-                               mmc->supply.vqmmc = ERR_PTR(-EINVAL);
-                       }
                        host->sdhci_core_to_disable_vqmmc = !ret;
                }
 
@@ -4402,6 +4397,13 @@ int sdhci_setup_host(struct sdhci_host *host)
                if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 2700000,
                                                    3600000))
                        host->flags &= ~SDHCI_SIGNALING_330;
+
+               if (ret) {
+                       pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
+                               mmc_hostname(mmc), ret);
+                       mmc->supply.vqmmc = ERR_PTR(-EINVAL);
+               }
+
        }
 
        if (host->quirks2 & SDHCI_QUIRK2_NO_1_8_V) {
--

Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project