All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ruoyu Wang" <ruoyuw560@gmail.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] dmaengine: sprd: Fix runtime PM reference leak in probe
Date: Thu, 13 Aug 2026 15:49:10 +0000	[thread overview]
Message-ID: <20260813154911.3B55C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813153149.3953497-1-ruoyuw560@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Premature IRQ registration and incorrect devres teardown order leading to UAF or bus errors.
- [High] The interrupt handler accesses hardware registers without checking if the device is active.
--

--- Patch [1]: [PATCH] dmaengine: sprd: Fix runtime PM reference leak in probe ---
commit 274e07c9f2493c369c243df16cab2b58e4834d15
Author: Ruoyu Wang <ruoyuw560@gmail.com>

dmaengine: sprd: Fix runtime PM reference leak in probe

The commit modifies the error handling path in sprd_dma_probe() to
correctly unwind runtime PM state. If pm_runtime_get_sync() fails, it
now jumps to err_register to drop the reference without idling the
partially initialized device, and disables runtime PM before turning off
clocks.

> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index 087fea3af2e41..19b32a23c882d 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -1212,7 +1212,7 @@ static int sprd_dma_probe(struct platform_device *pdev)
>  
>  	ret = pm_runtime_get_sync(&pdev->dev);
>  	if (ret < 0)
> -		goto err_rpm;
> +		goto err_register;

[Severity: High]
This is a pre-existing issue, but does the devm cleanup order risk a NULL
pointer dereference or accessing unmapped memory on probe failure?

Looking at sprd_dma_probe(), the IRQ is requested before the device IO
memory is mapped:

drivers/dma/sprd-dma.c:sprd_dma_probe() {
    ...
	if (sdev->irq > 0) {
		ret = devm_request_irq(&pdev->dev, sdev->irq, dma_irq_handle,
				       0, "sprd_dma", (void *)sdev);
    ...
	sdev->glb_base = devm_platform_ioremap_resource(pdev, 0);
    ...
}

If an interrupt is already pending on the line, it could fire immediately
upon unmasking. This would cause dma_irq_handle() to read from
sdev->glb_base before it is initialized, resulting in a NULL pointer
dereference.

Additionally, because devm_request_irq() is called before
devm_platform_ioremap_resource(), devres will unmap the memory before
freeing the IRQ during probe failure teardown. If an interrupt fires during
this window, could the handler access unmapped memory?


[Severity: High]
This is also a pre-existing issue, but does the interrupt handler safely
access hardware registers when the device might be runtime suspended?

drivers/dma/sprd-dma.c:dma_irq_handle() {
    ...
	u32 irq_status = readl(sdev->glb_base + SPRD_DMA_GLB_INT_MSK_STS);
    ...
}

If a spurious interrupt occurs while the device is suspended and clocks are
disabled, dma_irq_handle() unconditionally reads from the hardware
register.

Should the handler verify the device's runtime PM state via
pm_runtime_get_if_active() before accessing registers to prevent a
synchronous external abort?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813153149.3953497-1-ruoyuw560@gmail.com?part=1

      reply	other threads:[~2026-08-13 15:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 15:31 [PATCH] dmaengine: sprd: Fix runtime PM reference leak in probe Ruoyu Wang
2026-08-13 15:49 ` sashiko-bot [this message]

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=20260813154911.3B55C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=ruoyuw560@gmail.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.