All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Joy Zou" <joy.zou@oss.nxp.com>
Cc: imx@lists.linux.dev, dmaengine@vger.kernel.org, vkoul@kernel.org,
	Frank.Li@kernel.org
Subject: Re: [PATCH v8 4/5] dmaengine: mcf-edma: enable runtime PM for eDMA engine and channel
Date: Wed, 25 Nov 2026 11:03:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-233190@kernel.org> (raw)
In-Reply-To: <20261125-b4-edma-runtime-opt-mo-v8-4-81345a3bfb52@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] dmaengine: mcf-edma: NULL deref in mcf_edma_probe() on
  unregistered chan_dev
- [Medium] dmaengine: mcf-edma: missing IRQ cleanup on error in
  mcf_edma_probe()
--

commit 85c2f32e55b99ebb674415cf8e3e58e89f3b5438
Author: Joy Zou <joy.zou@oss.nxp.com>

dmaengine: mcf-edma: enable runtime PM for eDMA engine and channel

This commit enables runtime PM for the ColdFire eDMA engine and its
channel devices during probe.

> diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
> index 9e1c6400c77be..b1b94639d4cc0 100644
> --- a/drivers/dma/mcf-edma-main.c
> +++ b/drivers/dma/mcf-edma-main.c
> @@ -8,6 +8,7 @@
>  #include <linux/dmaengine.h>
>  #include <linux/platform_device.h>
>  #include <linux/platform_data/dma-mcf-edma.h>
> +#include <linux/pm_runtime.h>
>  
>  #include "fsl-edma-common.h"
>  
> @@ -192,7 +193,9 @@ static int mcf_edma_probe(struct platform_device *pdev)
>  	INIT_LIST_HEAD(&mcf_edma->dma_dev.channels);
>  	for (i = 0; i < mcf_edma->n_chans; i++) {
>  		struct fsl_edma_chan *mcf_chan = &mcf_edma->chans[i];
> +		struct device *chan_dev;
>  
> +		chan_dev = &mcf_chan->vchan.chan.dev->device;
>  		mcf_chan->edma = mcf_edma;
>  		mcf_chan->srcid = i;
>  		mcf_chan->dma_dir = DMA_NONE;
> @@ -201,6 +204,10 @@ static int mcf_edma_probe(struct platform_device *pdev)
>  		mcf_chan->tcd = mcf_edma->membase + EDMA_TCD
>  				+ i * sizeof(struct fsl_edma_hw_tcd);
>  		edma_write_tcdreg(mcf_chan, cpu_to_le32(0), csr);
> +		ret = devm_pm_runtime_enable(chan_dev);
> +		if (ret)
> +			return dev_err_probe(&pdev->dev, ret,
> +					     "Can't enable eDMA channel PM runtime!\n");
>  	}

[Severity: High]
Does devm_pm_runtime_enable(chan_dev) cause a NULL pointer dereference
when CONFIG_PM is enabled?

At this point in mcf_edma_probe(), mcf_chan->vchan.chan.dev is still NULL
because the per-channel struct dma_chan_dev is not allocated or registered
until dma_async_device_register() runs later in probe.  chan_dev is
therefore an offset from NULL, and devm_pm_runtime_enable(chan_dev)
immediately dereferences chan_dev->power.lock and chan_dev->devres_lock.

>  
>  	iowrite32(~0, regs->inth);
> @@ -240,6 +247,10 @@ static int mcf_edma_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, mcf_edma);
>  
> +	ret = devm_pm_runtime_enable(&pdev->dev);
> +	if (ret)
> +		return dev_err_probe(&pdev->dev, ret, "Can't enable eDMA engine PM runtime!\n");
> +

[Severity: Medium]
If devm_pm_runtime_enable(&pdev->dev) fails, does returning directly leak
the IRQs requested earlier by mcf_edma->drvdata->setup_irq() and leave
the vchan tasklets initialized?

mcf_edma_irq_init() registers its interrupt handlers with unmanaged
request_irq() using mcf_edma as the dev_id cookie.  When probe fails here,
devres frees mcf_edma and unmaps mcf_edma->membase while those IRQ
handlers remain active with a dangling mcf_edma pointer.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-b4-edma-runtime-opt-mo-v8-0-81345a3bfb52@oss.nxp.com?part=4

  reply	other threads:[~2026-11-25 11:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 10:58 [PATCH v8 0/5] add runtime suspend/resume support joy.zou
2026-11-25 10:58 ` [PATCH v8 1/5] dmaengine: fsl-edma: use devm_clk_get_optional_enabled() for channel clock joy.zou
2026-11-25 10:58 ` [PATCH v8 2/5] dmaengine: fsl-edma: use devm_clk_get_optional() for DMA engine clock joy.zou
2026-11-25 10:58 ` [PATCH v8 3/5] dmaengine: fsl-edma: convert DMAMUX clock handling to bulk clock API joy.zou
2026-11-25 10:58 ` [PATCH v8 4/5] dmaengine: mcf-edma: enable runtime PM for eDMA engine and channel Joy Zou
2026-11-25 11:03   ` sashiko-bot [this message]
2026-11-25 10:58 ` [PATCH v8 5/5] dmaengine: fsl-edma: add runtime suspend/resume support Joy Zou
2026-11-25 11:23   ` sashiko-bot

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=sashiko-outbox-233190@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=joy.zou@oss.nxp.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@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 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.