linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] mmc: sdhci: Allow platform controlled voltage switching
@ 2020-07-09  9:43 dan.carpenter
  2020-07-09 10:01 ` Veerabhadrarao Badiganti
  0 siblings, 1 reply; 2+ messages in thread
From: dan.carpenter @ 2020-07-09  9:43 UTC (permalink / raw)
  To: vviswana; +Cc: linux-mmc

Hello Vijay Viswanath,

The patch f870b6d480d3: "mmc: sdhci: Allow platform controlled
voltage switching" from Jun 23, 2020, leads to the following static
checker warning:

	drivers/mmc/host/sdhci.c:4396 sdhci_setup_host()
	warn: potential ERR_PTR parameter dereference 'mmc->supply.vqmmc'

drivers/mmc/host/sdhci.c
  4375          if (host->caps & SDHCI_CAN_DO_HISPD)
  4376                  mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
  4377  
  4378          if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
  4379              mmc_card_is_removable(mmc) &&
  4380              mmc_gpio_get_cd(host->mmc) < 0)
  4381                  mmc->caps |= MMC_CAP_NEEDS_POLL;
  4382  
  4383          if (!IS_ERR(mmc->supply.vqmmc)) {
  4384                  if (enable_vqmmc) {
  4385                          ret = regulator_enable(mmc->supply.vqmmc);
  4386                          if (ret) {
  4387                                  pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
  4388                                          mmc_hostname(mmc), ret);
  4389                                  mmc->supply.vqmmc = ERR_PTR(-EINVAL);
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is an error pointer.

  4390                          }
  4391                          host->sdhci_core_to_disable_vqmmc = !ret;
  4392                  }
  4393  
  4394                  /* If vqmmc provides no 1.8V signalling, then there's no UHS */
  4395                  if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 1700000,
                                                            ^^^^^^^^^^^^^^^^^
It is dereferenced inside the function and will crash.

  4396                                                      1950000))
  4397                          host->caps1 &= ~(SDHCI_SUPPORT_SDR104 |
  4398                                           SDHCI_SUPPORT_SDR50 |
  4399                                           SDHCI_SUPPORT_DDR50);
  4400  
  4401                  /* In eMMC case vqmmc might be a fixed 1.8V regulator */
  4402                  if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 2700000,
  4403                                                      3600000))
  4404                          host->flags &= ~SDHCI_SIGNALING_330;
  4405          }
  4406  

regards,
dan carpenter

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

* Re: [bug report] mmc: sdhci: Allow platform controlled voltage switching
  2020-07-09  9:43 [bug report] mmc: sdhci: Allow platform controlled voltage switching dan.carpenter
@ 2020-07-09 10:01 ` Veerabhadrarao Badiganti
  0 siblings, 0 replies; 2+ messages in thread
From: Veerabhadrarao Badiganti @ 2020-07-09 10:01 UTC (permalink / raw)
  To: dan.carpenter, vviswana; +Cc: linux-mmc

Hi,

Thanks for reporting this issue. Will post a patch to fix this issue.

Thanks
Veera

On 7/9/2020 3:13 PM, dan.carpenter@oracle.com wrote:
> Hello Vijay Viswanath,
>
> The patch f870b6d480d3: "mmc: sdhci: Allow platform controlled
> voltage switching" from Jun 23, 2020, leads to the following static
> checker warning:
>
> 	drivers/mmc/host/sdhci.c:4396 sdhci_setup_host()
> 	warn: potential ERR_PTR parameter dereference 'mmc->supply.vqmmc'
>
> drivers/mmc/host/sdhci.c
>    4375          if (host->caps & SDHCI_CAN_DO_HISPD)
>    4376                  mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
>    4377
>    4378          if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
>    4379              mmc_card_is_removable(mmc) &&
>    4380              mmc_gpio_get_cd(host->mmc) < 0)
>    4381                  mmc->caps |= MMC_CAP_NEEDS_POLL;
>    4382
>    4383          if (!IS_ERR(mmc->supply.vqmmc)) {
>    4384                  if (enable_vqmmc) {
>    4385                          ret = regulator_enable(mmc->supply.vqmmc);
>    4386                          if (ret) {
>    4387                                  pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
>    4388                                          mmc_hostname(mmc), ret);
>    4389                                  mmc->supply.vqmmc = ERR_PTR(-EINVAL);
>                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This is an error pointer.
>
>    4390                          }
>    4391                          host->sdhci_core_to_disable_vqmmc = !ret;
>    4392                  }
>    4393
>    4394                  /* If vqmmc provides no 1.8V signalling, then there's no UHS */
>    4395                  if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 1700000,
>                                                              ^^^^^^^^^^^^^^^^^
> It is dereferenced inside the function and will crash.
>
>    4396                                                      1950000))
>    4397                          host->caps1 &= ~(SDHCI_SUPPORT_SDR104 |
>    4398                                           SDHCI_SUPPORT_SDR50 |
>    4399                                           SDHCI_SUPPORT_DDR50);
>    4400
>    4401                  /* In eMMC case vqmmc might be a fixed 1.8V regulator */
>    4402                  if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 2700000,
>    4403                                                      3600000))
>    4404                          host->flags &= ~SDHCI_SIGNALING_330;
>    4405          }
>    4406
>
> regards,
> dan carpenter

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

end of thread, other threads:[~2020-07-09 10:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09  9:43 [bug report] mmc: sdhci: Allow platform controlled voltage switching dan.carpenter
2020-07-09 10:01 ` Veerabhadrarao Badiganti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).