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 04/10] dmaengine: dw-axi-dmac: Use bus width capability helpers
Date: Fri, 11 Sep 2026 17:40:11 +0000	[thread overview]
Message-ID: <20260911174012.0E7A71F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260911-dmaengine-support-wider-dma-masks-v4-4-72b8fd4cc78e@analog.com>

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

Pre-existing issues:
- [High] The interrupt handler is registered with IRQF_SHARED before channel registers are initialized, risking a fatal NULL pointer dereference.
- [High] Out-of-bounds write in axi_req_irqs due to unbounded irq_count from platform metadata.
- [High] Missing check for negative error code from platform_irq_count silently aborts IRQ registration but falsely returns success.
--

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

dmaengine: dw-axi-dmac: Use bus width capability helpers

Advertise the supported bus widths through dma_bus_width_set_many()
instead of assigning the legacy u32 masks directly. This keeps the
driver using the new bitmap representation while preserving legacy
fields during the transition.

> diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> index eebed2474210d..ca0ab8dc5f596 100644
> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
[ ... ]
> @@ -1482,6 +1469,20 @@ static int dw_probe(struct platform_device *pdev)
>  	unsigned int flags;
>  	u32 i;
>  	int ret;
> +	/*
> +	 * The set of bus widths supported by the DMA controller. DW AXI DMAC
> +	 * supports master data bus width up to 512 bits (for both AXI master
> +	 * interfaces), but it depends on IP block configuration.
> +	 */
> +	enum dma_slave_buswidth buswidths[] = {
> +		DMA_SLAVE_BUSWIDTH_1_BYTE,
> +		DMA_SLAVE_BUSWIDTH_2_BYTES,
> +		DMA_SLAVE_BUSWIDTH_4_BYTES,
> +		DMA_SLAVE_BUSWIDTH_8_BYTES,
> +		DMA_SLAVE_BUSWIDTH_16_BYTES,
> +		DMA_SLAVE_BUSWIDTH_32_BYTES,
> +		DMA_SLAVE_BUSWIDTH_64_BYTES,
> +	};
>  
>  	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
>  	if (!chip)

[Severity: High]
This is a pre-existing issue, but does axi_req_irqs() properly handle a
negative error code from platform_irq_count()?

If platform_irq_count() returns a negative error (like -EPROBE_DEFER):

drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:axi_req_irqs() {
    ...
    int irq_count = platform_irq_count(pdev);

    for (i = 0; i < irq_count; i++) {
        ...
    }
    return 0;
}

The loop will evaluate to false immediately, and the function falsely
returns 0. This silently aborts IRQ registration and causes dw_probe() to
continue without deferring probe or registering interrupts.


[Severity: High]
This is a pre-existing issue, but can the loop in axi_req_irqs() cause an
out-of-bounds write?

drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:axi_req_irqs() {
    ...
    int irq_count = platform_irq_count(pdev);

    for (i = 0; i < irq_count; i++) {
        chip->irq[i] = platform_get_irq(pdev, i);
        ...
    }
}

The chip->irq array has a fixed size of DMAC_MAX_CHANNELS (32). If
platform_irq_count() returns an unbounded value greater than 32 from the
platform metadata, this will write past the end of the array and corrupt
adjacent memory.


[Severity: High]
This is a pre-existing issue, but could there be a NULL pointer dereference
if a shared interrupt fires early during dw_probe()?

In axi_req_irqs(), the interrupt is registered with IRQF_SHARED:

drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:axi_req_irqs() {
    ...
        ret = devm_request_irq(chip->dev, chip->irq[i], dw_axi_dma_interrupt,
                               IRQF_SHARED, KBUILD_MODNAME, chip);
    ...
}

However, the channel registers are initialized after this call returns,
in dw_probe():

drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:dw_probe() {
    ...
    ret = axi_req_irqs(pdev, chip);
    if (ret)
        return ret;

    INIT_LIST_HEAD(&dw->dma.channels);
    for (i = 0; i < hdata->nr_channels; i++) {
        struct axi_dma_chan *chan = &dw->chan[i];
        ...
        chan->chan_regs = chip->regs + COMMON_REG_LEN + i * CHAN_REG_LEN;
    ...
}

If another device sharing the same IRQ line triggers an interrupt before
the channel registers are initialized, dw_axi_dma_interrupt() will read
from the uninitialized (NULL) chan->chan_regs:

drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:dw_axi_dma_interrupt() {
    ...
    for (i = 0; i < dw->hdata->nr_channels; i++) {
        chan = &dw->chan[i];
        status = axi_chan_irq_read(chan);
        ...
    }
}

Will this cause a panic if the handler tries to access chan->chan_regs?

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

  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 [this message]
2026-09-11 17:25 ` [PATCH v4 05/10] dmaengine: qcom: gpi: " Nuno Sá
2026-09-11 17:40   ` sashiko-bot
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=20260911174012.0E7A71F00898@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