From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, "Wolfram Sang" <wsa+renesas@sang-engineering.com>,
"Ulf Hansson" <ulfh@kernel.org>,
"Lad Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
"Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 06/13] mmc: renesas_sdhi: Guard host->cmd access in internal DMAC issue work
Date: Mon, 23 Nov 2026 19:15:50 +0000 [thread overview]
Message-ID: <20261123191703.179283-7-lee@kernel.org> (raw)
In-Reply-To: <20261123191703.179283-1-lee@kernel.org>
renesas_sdhi_internal_dmac_issue_work_fn() unmasks TMIO_STAT_DATAEND and
dereferences host->cmd without holding host->lock or checking that
host->cmd is still non-NULL. If tmio_mmc_reset_work() times out and
clears host->cmd under host->lock after tmio_mmc_cmd_irq() queues
host->dma_issue, or if unmasking TMIO_STAT_DATAEND allows a concurrent
data-end error completion to clear host->cmd via
tmio_mmc_finish_request(), evaluating host->cmd->error triggers a NULL
pointer dereference. Unmasking TMIO_STAT_DATAEND outside host->lock
also races with concurrent updates to host->sdcard_irq_mask.
Acquire host->lock across renesas_sdhi_internal_dmac_issue_work_fn() and
bail out if host->cmd has already been cleared, matching the sibling
system DMAC implementation.
Fixes: c330601c9c93 ("mmc: renesas_sdhi: take DMA end interrupts into account")
Closes: https://sashiko.dev/#/bug/linux-57271e16-2f7e-4151-a686-57ab2474fe6f
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/mmc/host/renesas_sdhi_internal_dmac.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
index 0c3967f758c2..6831fc34cd22 100644
--- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
@@ -450,6 +450,13 @@ static void renesas_sdhi_internal_dmac_issue_work_fn(struct work_struct *work)
{
struct tmio_mmc_host *host = from_work(host, work, dma_issue);
struct renesas_sdhi *priv = host_to_priv(host);
+ unsigned long flags;
+
+ spin_lock_irqsave(&host->lock, flags);
+ if (!host->cmd) {
+ spin_unlock_irqrestore(&host->lock, flags);
+ return;
+ }
tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND);
@@ -462,6 +469,7 @@ static void renesas_sdhi_internal_dmac_issue_work_fn(struct work_struct *work)
if (test_bit(SDHI_DMA_END_FLAG_ACCESS, &priv->dma_priv.end_flags))
queue_work(system_bh_wq, &priv->dma_priv.dma_complete);
}
+ spin_unlock_irqrestore(&host->lock, flags);
}
static bool renesas_sdhi_internal_dmac_complete(struct tmio_mmc_host *host)
--
2.56.1.750.gf70dc682cf-goog
next prev parent reply other threads:[~2026-11-23 19:18 UTC|newest]
Thread overview: 34+ 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 ` 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 ` Lee Jones
2026-11-27 23:18 ` Valerio Setti
2026-11-27 23:18 ` Valerio Setti
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 ` Lee Jones [this message]
2026-11-23 19:15 ` [PATCH 07/13] mmc: tifm_sd: Synchronise timeout handler with request completion Lee Jones
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-24 1:45 ` Shawn Lin
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
2026-11-23 19:31 ` Florian Fainelli
2026-11-25 13:37 ` [PATCH 00/13] mmc: Assorted bug fixes across MMC host drivers Biju Das
2026-11-25 13:37 ` Biju Das
2026-11-25 15:08 ` wsa+renesas
2026-11-25 15:08 ` wsa+renesas
2026-11-25 18:02 ` Biju Das
2026-11-25 18:02 ` Biju Das
2026-11-25 17:50 ` Markus Elfring
2026-11-25 17:50 ` Markus Elfring
2026-11-26 8:53 ` Lee Jones
2026-11-26 8:53 ` Lee Jones
2026-11-26 9:23 ` [00/13] " Markus Elfring
2026-11-26 9:23 ` Markus Elfring
2026-11-26 11:29 ` Lee Jones
2026-11-26 11:29 ` 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-7-lee@kernel.org \
--to=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
--cc=ulfh@kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.