Linux-mmc Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH V1] mmc: sdhci: Fix potential null pointer access while accessing vqmmc
@ 2020-07-09 13:13 Veerabhadrarao Badiganti
  2020-07-10  7:58 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Veerabhadrarao Badiganti @ 2020-07-09 13:13 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson, dan.carpenter
  Cc: linux-mmc, linux-kernel, linux-arm-msm, Veerabhadrarao Badiganti,
	Vijay Viswanath

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

Fixes: f870b6d480d3 (mmc: sdhci: Allow platform controlled voltage switching)
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
---
 drivers/mmc/host/sdhci.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index e6275c2202b0..d3b62fc5c661 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH V1] mmc: sdhci: Fix potential null pointer access while accessing vqmmc
  2020-07-09 13:13 [PATCH V1] mmc: sdhci: Fix potential null pointer access while accessing vqmmc Veerabhadrarao Badiganti
@ 2020-07-10  7:58 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2020-07-10  7:58 UTC (permalink / raw)
  To: Veerabhadrarao Badiganti
  Cc: Adrian Hunter, Dan Carpenter, linux-mmc,
	Linux Kernel Mailing List, linux-arm-msm, Vijay Viswanath

On Thu, 9 Jul 2020 at 15:13, Veerabhadrarao Badiganti
<vbadigan@codeaurora.org> wrote:
>
> Don't access vqmmc regulator handler, if it's already invalidated.
>
> Fixes: f870b6d480d3 (mmc: sdhci: Allow platform controlled voltage switching)
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>

Applied for next, thanks!

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index e6275c2202b0..d3b62fc5c661 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 13:13 [PATCH V1] mmc: sdhci: Fix potential null pointer access while accessing vqmmc Veerabhadrarao Badiganti
2020-07-10  7:58 ` Ulf Hansson

Linux-mmc Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mmc/0 linux-mmc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mmc linux-mmc/ https://lore.kernel.org/linux-mmc \
		linux-mmc@vger.kernel.org
	public-inbox-index linux-mmc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mmc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git