Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6bdf4fce authored by Bao D. Nguyen's avatar Bao D. Nguyen
Browse files

mmc: core: Fix error when SD card is removed



The device reboots when the SD card is removed.
This is because the host->claimer resource has been released
earlier as part of the SD card removal process.
When mmc_try_claim_host tries to check the host->claimer->task,
it dereferences a NULL pointer.

Change-Id: I8625b17e337248791de6fac2ba5b3a2d5e82894e
Signed-off-by: default avatarBao D. Nguyen <nguyenb@codeaurora.org>
parent 0a48238d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1787,12 +1787,13 @@ int mmc_try_claim_host(struct mmc_host *host, unsigned int delay_ms)
	unsigned long flags;
	int retry_cnt = delay_ms/10;
	bool pm = false;
	struct task_struct *task = current;

	do {
		spin_lock_irqsave(&host->lock, flags);
		if (!host->claimed || host->claimer->task == current) {
		if (!host->claimed || mmc_ctx_matches(host, NULL, task)) {
			host->claimed = 1;
			host->claimer->task = current;
			mmc_ctx_set_claimer(host, NULL, task);
			host->claim_cnt += 1;
			claimed_host = 1;
			if (host->claim_cnt == 1)
+0 −2
Original line number Diff line number Diff line
@@ -1197,8 +1197,6 @@ static void mmc_sd_detect(struct mmc_host *host)
		return;
	}

	mmc_get_card(host->card, NULL);

	/*
	 * Just check if our card has been removed.
	 */