DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nuno Sá" <nuno.sa@analog.com>
Cc: vkoul@kernel.org, dmaengine@vger.kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v4 05/10] dmaengine: qcom: gpi: Use bus width capability helpers
Date: Fri, 11 Sep 2026 17:40:00 +0000	[thread overview]
Message-ID: <20260911174000.919C31F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911-dmaengine-support-wider-dma-masks-v4-5-72b8fd4cc78e@analog.com>

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

Pre-existing issues:
- [High] Missing cleanup for DMA controller and async device registration in error paths and missing .remove method lead to UAF.
--

commit bbcb7726e80023f035efafba93cea9b1b9a4a1c3
Author: Nuno Sá <nuno.sa@analog.com>

dmaengine: qcom: gpi: Use bus width capability helpers

This commit uses the new dma_bus_width_set helper to advertise supported
bus widths, replacing legacy assignments.

> diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c
> index a5055a6273af6..3a35bf4c33978 100644
> --- a/drivers/dma/qcom/gpi.c
> +++ b/drivers/dma/qcom/gpi.c

[ ... ]

> @@ -2265,8 +2266,15 @@ static int gpi_probe(struct platform_device *pdev)
>  	/* configure dmaengine apis */
>  	gpi_dev->dma_device.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
>  	gpi_dev->dma_device.residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
> -	gpi_dev->dma_device.src_addr_widths = DMA_SLAVE_BUSWIDTH_8_BYTES;
> -	gpi_dev->dma_device.dst_addr_widths = DMA_SLAVE_BUSWIDTH_8_BYTES;
> +	ret = dma_bus_width_set(gpi_dev->dma_device.src_bus_widths,
> +				DMA_SLAVE_BUSWIDTH_8_BYTES);
> +	if (ret)
> +		return ret;
> +
> +	ret = dma_bus_width_set(gpi_dev->dma_device.dst_bus_widths,
> +				DMA_SLAVE_BUSWIDTH_8_BYTES);
> +	if (ret)
> +		return ret;

[Severity: High]
This is a pre-existing issue, but while looking at the changes in
gpi_probe, I noticed a potential memory corruption issue on the error
path and during driver unbind.

If of_dma_controller_register fails later in gpi_probe, it returns an
error without unregistering the previously registered async DMA device:

gpi_probe() {
    ...
    ret = dma_async_device_register(&gpi_dev->dma_device);
    if (ret) {
        dev_err(gpi_dev->dev, "async_device_register failed ret:%d", ret);
        return ret;
    }

    ret = of_dma_controller_register(gpi_dev->dev->of_node,
                                     gpi_of_dma_xlate, gpi_dev);
    if (ret) {
        dev_err(gpi_dev->dev, "of_dma_controller_reg failed ret:%d", ret);
        return ret;
    }
    ...
}

Additionally, the platform driver gpi_driver completely lacks a remove
callback. If the driver is manually unbound via sysfs, devres will free
the driver's memory while leaving the DMA device and OF controller globally
registered.

Could this lead to a use-after-free if the dangling dma_device pointer is
accessed by other subsystems? Should the error path and driver teardown
clean up these registrations?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260911-dmaengine-support-wider-dma-masks-v4-0-72b8fd4cc78e@analog.com?part=5

  reply	other threads:[~2026-09-11 17:40 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 17:25 [PATCH v4 00/10] dmaengine: Support bus widths of 32 bytes and above Nuno Sá
2026-09-11 17:25 ` [PATCH v4 01/10] dmaengine: Move enum dma_slave_buswidth to a new header Nuno Sá
2026-09-12  7:57   ` Andy Shevchenko
2026-09-14 14:18   ` Frank Li
2026-09-14 15:40     ` Nuno Sá
2026-09-15  7:29     ` Andy Shevchenko
2026-09-15 14:37       ` Frank Li
2026-09-15 14:53         ` Andy Shevchenko
2026-09-17 10:54           ` Nuno Sá
2026-09-17 12:29             ` Andy Shevchenko
2026-09-17 10:49         ` Nuno Sá
2026-09-17 14:38           ` Frank Li
2026-09-17 15:26             ` Nuno Sá
2026-09-18  8:25             ` Nuno Sá
2026-09-15 15:52       ` Vinod Koul
2026-09-15 16:20         ` Vinod Koul
2026-09-15 17:04           ` Frank Li
2026-09-17 18:09             ` Vinod Koul
2026-09-18  6:24               ` Andy Shevchenko
2026-09-18 18:01                 ` Vinod Koul
2026-09-18  8:39               ` Nuno Sá
2026-09-18 18:03                 ` Vinod Koul
2026-09-21  8:53                   ` Nuno Sá
2026-09-21 16:12                     ` Frank Li
2026-10-02 10:43                       ` Nuno Sá
2026-10-02 13:47                         ` Frank Li
2026-10-03 14:52                           ` Andy Shevchenko
2026-10-04  0:59                             ` Frank Li
2026-10-04  8:31                               ` Andy Shevchenko
2026-10-06  6:36                               ` Nuno Sá
2026-10-06  7:59                                 ` Frank Li
2026-10-06  9:47                                   ` Nuno Sá
2026-09-11 17:25 ` [PATCH v4 02/10] dmaengine: Support bus widths of 32 bytes and above Nuno Sá
2026-09-14  8:05   ` Andy Shevchenko
2026-09-11 17:25 ` [PATCH v4 03/10] dmaengine: dma-axi-dmac: Use bus width capability helpers Nuno Sá
2026-09-11 17:39   ` sashiko-bot
2026-09-11 17:25 ` [PATCH v4 04/10] dmaengine: dw-axi-dmac: " Nuno Sá
2026-09-11 17:40   ` sashiko-bot
2026-09-11 17:25 ` [PATCH v4 05/10] dmaengine: qcom: gpi: " Nuno Sá
2026-09-11 17:40   ` sashiko-bot [this message]
2026-09-11 17:25 ` [PATCH v4 06/10] dmaengine: stm32-dma3: " Nuno Sá
2026-09-11 17:25 ` [PATCH v4 07/10] iio: buffer-dmaengine: Use dma_slave_caps bus width accessors Nuno Sá
2026-09-14  8:06   ` Andy Shevchenko
2026-09-11 17:25 ` [PATCH v4 08/10] ALSA: pcm_dmaengine: Use dma_slave_caps bus width helpers Nuno Sá
2026-09-14  8:12   ` Andy Shevchenko
2026-09-14 15:39     ` Nuno Sá
2026-09-15  7:31       ` Andy Shevchenko
2026-09-15  8:13         ` Nuno Sá
2026-09-11 17:25 ` [PATCH v4 09/10] spi: dw: " Nuno Sá
2026-09-11 17:25 ` [PATCH v4 10/10] dmaengine: Drop legacy bus width fields from dma_slave_caps Nuno Sá

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=20260911174000.919C31F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=nuno.sa@analog.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox