[bug report] mmc: sdhci: Allow platform controlled voltage switching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux