From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Paul Cercueil <paul@crapouillou.net>,
Ulf Hansson <ulfh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Apelete Seketeli <apelete@seketeli.net>,
linux-mips@vger.kernel.org, linux-mmc@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 05/13] mmc: jz4740: Skip DMA cleanup in PIO mode during post_req
Date: Mon, 23 Nov 2026 19:15:49 +0000 [thread overview]
Message-ID: <20261123191703.179283-6-lee@kernel.org> (raw)
In-Reply-To: <20261123191703.179283-1-lee@kernel.org>
When DMA channel acquisition fails during probe, the JZ4740 MMC driver
falls back to PIO mode with host->use_dma set to false and host->dma_tx
or host->dma_rx left holding an ERR_PTR() or released channel pointer.
Unlike jz4740_mmc_pre_request(), jz4740_mmc_post_request() does not
check host->use_dma before calling dmaengine_terminate_all() on error,
resulting in an invalid or dangling DMA channel pointer dereference
whenever a PIO data transfer encounters an error.
Return early from jz4740_mmc_post_request() when host->use_dma is false,
matching jz4740_mmc_pre_request().
Fixes: bb2f45927f8e ("mmc: jz4740: prepare next dma transfer in parallel with current transfer")
Closes: https://sashiko.dev/#/bug/linux-735efbcb-99f8-4d4a-8814-aa31e3634f29
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/mmc/host/jz4740_mmc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index 923cf1450de5..e398a575f2dc 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -392,6 +392,9 @@ static void jz4740_mmc_post_request(struct mmc_host *mmc,
struct jz4740_mmc_host *host = mmc_priv(mmc);
struct mmc_data *data = mrq->data;
+ if (!host->use_dma)
+ return;
+
if (data && data->host_cookie != COOKIE_UNMAPPED)
jz4740_mmc_dma_unmap(host, data);
--
2.56.1.750.gf70dc682cf-goog
next prev parent reply other threads:[~2026-11-23 19:17 UTC|newest]
Thread overview: 3+ 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 [this message]
2026-11-23 19:15 ` [PATCH 10/13] mmc: jz4740: Apply DMA max_seg_size limit to unified tx-rx channel 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-6-lee@kernel.org \
--to=lee@kernel.org \
--cc=apelete@seketeli.net \
--cc=krzysztof.kozlowski@oss.qualcomm.com \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=paul@crapouillou.net \
--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