From: sashiko-bot@kernel.org
To: Frank.Li@oss.nxp.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org,
wsa+renesas@sang-engineering.com
Subject: Re: [PATCH v2 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev
Date: Fri, 18 Sep 2026 15:48:12 +0000 [thread overview]
Message-ID: <20260918154812.C05EE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260918152349.2101305-1-Frank.Li@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] mmc: mxcmmc: NULL pointer dereference in mxcmci_setup_data fallback to PIO
- [Medium] mmc: missed device->dev conversions in omap.c and mxs-mmc.c
--
commit fac187edba18928bfcb50c068ba67dea2103d2aa
Author: Frank Li <Frank.Li@nxp.com>
Subject: mmc: use dmaengine_get_dma_device() instead of chan->device->dev
This patch replaces direct dma_chan::device::dev access with the
dmaengine_get_dma_device() macro across the MMC subsystem. This change
prepares the subsystem for making the DMA engine provider data structures
private.
> mmc: use dmaengine_get_dma_device() instead of chan->device->dev
>
> Replace direct dma_chan::device::dev access with the proper
> dmaengine_get_dma_device() for consumer API
>
> chan->device->dev is not always the device used for DMA mapping.
> Some DMA engines support per-channel IOMMU mappings, so different
> channels may use different DMA devices. dmaengine_get_dma_device()
> returns the correct device for each channel.
>
> This also prepares for making the DMA engine provider data structures
> private. DMA consumers should not access DMA engine internals directly.
>
> Assisted-by: LLM
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
>
> ---
> Change in v2
> - find more place, which use device->dev for dma mapping. This time should
> clean all.
[Severity: Medium]
Does this patch catch all instances across the MMC subsystem?
The commit message mentions this should clean all occurrences, but there
appear to be remaining direct chan->device->dev accesses in
drivers/mmc/host/omap.c (e.g., c->device->dev in mmc_omap_prepare_data())
and drivers/mmc/host/mxs-mmc.c (ssp->dmach->device->dev in mxs_mmc_probe()).
These will likely cause compilation failures when the DMA engine fields are
actually made private.
[ ... ]
> diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
> index 097498a3f8ff4..c20cff770395e 100644
> --- a/drivers/mmc/host/mxcmmc.c
> +++ b/drivers/mmc/host/mxcmmc.c
> @@ -290,6 +290,7 @@ static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data)
> unsigned int datasize = nob * blksz;
> struct scatterlist *sg;
> enum dma_transfer_direction slave_dirn;
> + struct device *dma_dev = dmaengine_get_dma_device(host->dma);
[Severity: High]
Will this cause a NULL pointer dereference if the driver falls back to
PIO mode?
In mxcmci_probe(), if dma_request_chan() fails, host->dma is set to NULL to
fallback to PIO mode. However, in mxcmci_setup_data(), we now unconditionally
initialize dma_dev by calling dmaengine_get_dma_device(host->dma) before the
!mxcmci_use_dma(host) check happens. This macro dereferences the channel
pointer to access chan->chan_dev->chan_dma_dev, which will crash upon the
first PIO data transfer if host->dma is NULL.
> int i, nents;
>
> host->data = data;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260918152349.2101305-1-Frank.Li@oss.nxp.com?part=1
next prev parent reply other threads:[~2026-09-18 15:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 15:23 [PATCH v2 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev Frank.Li
2026-09-18 15:48 ` sashiko-bot [this message]
2026-09-18 17:50 ` Vinod Koul
2026-09-18 19:03 ` Wolfram Sang
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=20260918154812.C05EE1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=Frank.Li@oss.nxp.com \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox