From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Alex Dubov <oakad@yahoo.com>,
Ulf Hansson <ulfh@kernel.org>, Pierre Ossman <drzeus@drzeus.cx>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 07/13] mmc: tifm_sd: Synchronise timeout handler with request completion
Date: Mon, 23 Nov 2026 19:15:51 +0000 [thread overview]
Message-ID: <20261123191703.179283-8-lee@kernel.org> (raw)
In-Reply-To: <20261123191703.179283-1-lee@kernel.org>
tifm_sd_end_cmd() deletes host->timer with timer_delete() under
sock->lock, clears host->req to NULL, and completes the request via
mmc_request_done(). Because timer_delete() does not wait for an already
executing timer callback and tifm_sd_abort() reads the active command
opcode from host->req without holding sock->lock, a concurrent timeout
expiry can dereference a NULL or freed struct mmc_request and spuriously
eject the card after the request has already completed.
Serialise tifm_sd_abort() on sock->lock, return early if host->req has
already been cleared or the socket is being ejected, and snapshot the
command opcode and flags before releasing sock->lock prior to calling
tifm_eject().
Fixes: 91f8d0118a0e ("tifm: layout fixes, small changes to comments and printfs")
Closes: https://sashiko.dev/#/bug/linux-6535b228-4464-4a24-8fea-e969201c0f95
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/mmc/host/tifm_sd.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c
index 28ab2526dab1..30935214d17c 100644
--- a/drivers/mmc/host/tifm_sd.c
+++ b/drivers/mmc/host/tifm_sd.c
@@ -776,12 +776,24 @@ static void tifm_sd_end_cmd(struct work_struct *t)
static void tifm_sd_abort(struct timer_list *t)
{
struct tifm_sd *host = timer_container_of(host, t, timer);
+ struct tifm_dev *sock = host->dev;
+ unsigned int opcode, cmd_flags;
+ unsigned long flags;
+
+ spin_lock_irqsave(&sock->lock, flags);
+ if (!host->req || host->eject) {
+ spin_unlock_irqrestore(&sock->lock, flags);
+ return;
+ }
+ opcode = host->req->cmd->opcode;
+ cmd_flags = host->cmd_flags;
+ spin_unlock_irqrestore(&sock->lock, flags);
pr_err("%s : card failed to respond for a long period of time "
"(%x, %x)\n",
- dev_name(&host->dev->dev), host->req->cmd->opcode, host->cmd_flags);
+ dev_name(&sock->dev), opcode, cmd_flags);
- tifm_eject(host->dev);
+ tifm_eject(sock);
}
static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
--
2.56.1.750.gf70dc682cf-goog
next prev parent reply other threads:[~2026-11-23 19:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 19:15 [PATCH 00/13] mmc: Assorted bug fixes across MMC host drivers Lee Jones
2026-11-23 19:15 ` [PATCH 01/13] mmc: cavium: Remove MMC slots before destroying slot platform devices Lee Jones
2026-11-23 19:15 ` [PATCH 02/13] mmc: cavium: Prevent slot_pdev[] out-of-bounds write during probe Lee Jones
2026-11-23 19:15 ` [PATCH 03/13] mmc: sdhci-msm: Resume runtime PM before accessing registers on remove Lee Jones
2026-11-23 19:15 ` [PATCH 04/13] mmc: meson-gx: Fail request when descriptor chain DMA mapping fails Lee Jones
2026-11-23 19:15 ` [PATCH 05/13] mmc: jz4740: Skip DMA cleanup in PIO mode during post_req Lee Jones
2026-11-23 19:15 ` [PATCH 06/13] mmc: renesas_sdhi: Guard host->cmd access in internal DMAC issue work Lee Jones
2026-11-23 19:15 ` Lee Jones [this message]
2026-11-23 19:15 ` [PATCH 08/13] mmc: omap: Shut down cover timer before disabling cover BH work Lee Jones
2026-11-23 19:15 ` [PATCH 09/13] mmc: renesas_sdhi: Disable internal DMAC BH work items on release Lee Jones
2026-11-23 19:15 ` [PATCH 10/13] mmc: jz4740: Apply DMA max_seg_size limit to unified tx-rx channel Lee Jones
2026-11-23 19:15 ` [PATCH 11/13] mmc: dw_mmc: Disarm central watchdog when ending a request Lee Jones
2026-11-23 19:15 ` [PATCH 12/13] mmc: renesas_sdhi: Fix SDIO manual tap correction in SDR104 mode Lee Jones
2026-11-23 19:15 ` [PATCH 13/13] mmc: sdhci-brcmstb: Handle absent optional sdio_freq clock in probe Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123191703.179283-8-lee@kernel.org \
--to=lee@kernel.org \
--cc=drzeus@drzeus.cx \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=oakad@yahoo.com \
--cc=stable@vger.kernel.org \
--cc=ulfh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox