Commit 14efd957 authored by Chris Ball's avatar Chris Ball

mmc: sdhci: fix NULL dereference in sdhci_request() tuning

Commit 473b095a ("mmc: sdhci: fix incorrect command used in tuning")
introduced a NULL dereference at resume-time if an SD 3.0 host controller
raises the SDHCI_NEEDS_TUNING flag while no card is inserted.  Seen on an
OLPC XO-4 with sdhci-pxav3, but presumably affects other controllers too.
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
Cc: stable <stable@vger.kernel.org> [3.3+]
parent 657d5982
...@@ -1315,16 +1315,19 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) ...@@ -1315,16 +1315,19 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
*/ */
if ((host->flags & SDHCI_NEEDS_RETUNING) && if ((host->flags & SDHCI_NEEDS_RETUNING) &&
!(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) { !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) {
/* eMMC uses cmd21 while sd and sdio use cmd19 */ if (mmc->card) {
tuning_opcode = mmc->card->type == MMC_TYPE_MMC ? /* eMMC uses cmd21 but sd and sdio use cmd19 */
MMC_SEND_TUNING_BLOCK_HS200 : tuning_opcode =
MMC_SEND_TUNING_BLOCK; mmc->card->type == MMC_TYPE_MMC ?
spin_unlock_irqrestore(&host->lock, flags); MMC_SEND_TUNING_BLOCK_HS200 :
sdhci_execute_tuning(mmc, tuning_opcode); MMC_SEND_TUNING_BLOCK;
spin_lock_irqsave(&host->lock, flags); spin_unlock_irqrestore(&host->lock, flags);
sdhci_execute_tuning(mmc, tuning_opcode);
/* Restore original mmc_request structure */ spin_lock_irqsave(&host->lock, flags);
host->mrq = mrq;
/* Restore original mmc_request structure */
host->mrq = mrq;
}
} }
if (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23)) if (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment