[PATCH] mmc/core:fix mmc_sd_hw_reset oops mmc_sd_hw_reset function may be oops if the ejection of sd and the reset of sd simultaneously occur
From: yanxiaoyong5
Date: Fri May 01 2020 - 12:00:39 EST
Signed-off-by: yanxiaoyong5 <yanxiaoyong5@xxxxxxxxx>
---
drivers/mmc/core/sd.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index fe914ff..73a1e68 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1247,8 +1247,13 @@ static int mmc_sd_runtime_resume(struct mmc_host *host)
static int mmc_sd_hw_reset(struct mmc_host *host)
{
- mmc_power_cycle(host, host->card->ocr);
- return mmc_sd_init_card(host, host->card->ocr, host->card);
+ struct mmc_card *card;
+
+ card = host->card;
+ if (!card)
+ return -EINVAL;
+ mmc_power_cycle(host, card->ocr);
+ return mmc_sd_init_card(host, card->ocr, host->card);
}
static const struct mmc_bus_ops mmc_sd_ops = {
--
2.7.4