From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH] dmaengine: ppc4xx: check dma_map_page() errors in probe
Date: Thu, 10 Sep 2026 21:48:13 +0000 [thread overview]
Message-ID: <20260910214814.0B7C91F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260910214334.86689-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The error paths for dma_map_page() failures use `goto out;`, bypassing all resource cleanup and causing a massive memory and resource leak.
--
commit e542c1430356273e51891dbcad4333a7ba32009f
Author: Rosen Penev <rosenp@gmail.com>
dmaengine: ppc4xx: check dma_map_page() errors in probe
This commit adds validation for the DMA addresses returned by dma_map_page() in
ppc440spe_adma_probe(). It fails the probe and frees the pages when a mapping
error occurs to avoid corrupting data.
> diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
> index 279a431ccae38..89e778896d7a5 100644
> --- a/drivers/dma/ppc4xx/adma.c
> +++ b/drivers/dma/ppc4xx/adma.c
[ ... ]
> @@ -4156,8 +4156,22 @@ static int ppc440spe_adma_probe(struct platform_device *ofdev)
> }
> chan->pdest = dma_map_page(&ofdev->dev, chan->pdest_page, 0,
> PAGE_SIZE, DMA_BIDIRECTIONAL);
> + if (dma_mapping_error(&ofdev->dev, chan->pdest)) {
> + __free_page(chan->pdest_page);
> + __free_page(chan->qdest_page);
> + ret = -ENOMEM;
> + goto out;
[Severity: High]
Does jumping directly to out bypass the necessary cleanup for chan, adev, the
dma_desc_pool, and the ioremap regions?
It looks like earlier errors in ppc440spe_adma_probe() jump to specific error
labels (such as err_page_alloc) to unwind and free these resources. If the
pdest mapping fails, jumping directly to out instead of the proper error labels
appears to leak the channel structure and device resources.
> + }
> chan->qdest = dma_map_page(&ofdev->dev, chan->qdest_page, 0,
> PAGE_SIZE, DMA_BIDIRECTIONAL);
> + if (dma_mapping_error(&ofdev->dev, chan->qdest)) {
> + dma_unmap_page(&ofdev->dev, chan->pdest,
> + PAGE_SIZE, DMA_BIDIRECTIONAL);
> + __free_page(chan->pdest_page);
> + __free_page(chan->qdest_page);
> + ret = -ENOMEM;
> + goto out;
[Severity: High]
Similarly, does this goto also leak the chan structure, adev, dma_desc_pool,
and ioremap regions when the qdest mapping fails?
Jumping to err_page_alloc might correctly unwind the allocations made earlier
in the probe function after the pages are freed.
> + }
> }
>
> ref = kmalloc_obj(*ref);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260910214334.86689-1-rosenp@gmail.com?part=1
next prev parent reply other threads:[~2026-09-10 21:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 21:43 [PATCH] dmaengine: ppc4xx: check dma_map_page() errors in probe Rosen Penev
2026-09-10 21:48 ` sashiko-bot [this message]
2026-09-11 16:05 ` Frank Li
2026-09-11 18:10 ` Rosen Penev
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=20260910214814.0B7C91F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=rosenp@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.