From e5ac7ee2f8fb00d7d00af3f726e5ad519ffa1f3e Mon Sep 17 00:00:00 2001 From: Sarthak Garg Date: Tue, 23 Feb 2021 10:28:20 +0530 Subject: [PATCH] mmc: core: Set host->bus_refs properly when card is set as corrupted With rapid hotplug test case there could be a corner case when the SD card can go bad and removed quickly even before we try to reset the card as part of recovery. This will lead to reset failure with ENOMEDIUM and since recovery failed so we set the corrupted_card flag and try to remove the card. Since corrupted_card will be set so as part of rescan we'll remove the card and return before setting the bus_refs properly leading to card not getting detected after this. Only return after setting host->bus_refs properly when card is set as corrupted. Change-Id: Id14790f9b28d8fa58d31b034be48db5486ccfcb7 Signed-off-by: Sarthak Garg --- drivers/mmc/core/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 9544076998ff..13b58096feb6 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -3154,11 +3154,6 @@ void mmc_rescan(struct work_struct *work) if (host->bus_ops && !host->bus_dead) host->bus_ops->detect(host); -#if defined(CONFIG_SDC_QTI) - if (host->corrupted_card) - return; -#endif - host->detect_change = 0; /* @@ -3180,6 +3175,11 @@ void mmc_rescan(struct work_struct *work) */ mmc_bus_put(host); +#if defined(CONFIG_SDC_QTI) + if (host->corrupted_card) + goto out; +#endif + mmc_claim_host(host); if (mmc_card_is_removable(host) && host->ops->get_cd && host->ops->get_cd(host) == 0) {