diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 783f512538c..ee5a4541472 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1045,6 +1045,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, err = mmc_send_relative_addr(host, &card->rca); if (err) return err; + host->card = card; } if (!oldcard) { @@ -1114,12 +1115,13 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, } } - host->card = card; return 0; free_card: - if (!oldcard) + if (!oldcard) { + host->card = NULL; mmc_remove_card(card); + } return err; }