DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Koichiro Den" <den@valinux.co.jp>
Cc: vkoul@kernel.org, dmaengine@vger.kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH 2/4] dmaengine: dw-edma-pcie: Reject devices without driver data
Date: Thu, 21 May 2026 15:15:03 +0000	[thread overview]
Message-ID: <20260521151504.69BA61F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260521142153.2957432-3-den@valinux.co.jp>

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

New issues:
- [Medium] Mixing goto-based error handling with scope-based cleanup (__free) in the same function.

Pre-existing issues:
- [High] Missing bounds check for the hardware-provided BAR index when accessing the `pcim_iomap_table()` array.
--

commit 451669b3f83e6d7ef131e591fd15b9e144ab9005
Author: Koichiro Den <den@valinux.co.jp>
Subject: dmaengine: dw-edma-pcie: Reject devices without driver data

This commit adds a check to reject devices without driver data during
dw_edma_pcie_probe. This prevents a NULL pointer dereference when a device
bound dynamically via sysfs matches the driver without that data.

> diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c
> index 87c31d01fb102..c2024fa824e03 100644
> --- a/drivers/dma/dw-edma/dw-edma-pcie.c
> +++ b/drivers/dma/dw-edma/dw-edma-pcie.c
> @@ -314,6 +314,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
>  	int i, mask;
>  	bool non_ll = false;
>  
> +	if (!pdata)
> +		return -ENODEV;
> +
>  	struct dw_edma_pcie_data *vsec_data __free(kfree) =
>  		kmalloc_obj(*vsec_data);

[Severity: Medium]
The kernel's cleanup subsystem guidelines state that goto-based error
handling and scope-based cleanup should not be mixed in the same function.

Since dw_edma_pcie_probe() uses goto-based cleanup labels on failure paths
like goto err_free_irq_vectors, could mixing them with the __free attribute
here lead to confusing ownership semantics or resource tracking bugs?

Would it be better to either convert all cleanups in this function to
scope-based guards, or avoid using the __free attribute entirely?

[ ... ]

>  	chip->ll_wr_cnt = vsec_data->wr_ch_cnt;
>  	chip->ll_rd_cnt = vsec_data->rd_ch_cnt;
>  
>  	chip->reg_base = pcim_iomap_table(pdev)[vsec_data->rg.bar];

[Severity: High]
This is a pre-existing issue, but does this code properly validate the
hardware-provided BAR index before using it as an array index?

The value for vsec_data->rg.bar is extracted from the PCIe VSEC
capabilities, which can yield values up to 7. However,
pcim_iomap_table(pdev) returns a pointer to an array of size
PCI_STD_NUM_BARS, which is 6.

If a misconfigured or malicious device provides a BAR index of 6 or 7,
could accessing this array result in an out-of-bounds memory read and
crash the kernel when the resulting invalid pointer is dereferenced?

>  	if (!chip->reg_base) {
>  		err = -ENOMEM;
>  		goto err_free_irq_vectors;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260521142153.2957432-1-den@valinux.co.jp?part=2

  parent reply	other threads:[~2026-05-21 15:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21 14:21 [PATCH 0/4] dmaengine: dw-edma: Fix probe paths and register races Koichiro Den
2026-05-21 14:21 ` [PATCH 1/4] dmaengine: dw-edma-pcie: Free IRQ vectors on probe failures Koichiro Den
2026-05-21 14:39   ` Frank Li
2026-05-21 15:02     ` Koichiro Den
2026-05-21 14:21 ` [PATCH 2/4] dmaengine: dw-edma-pcie: Reject devices without driver data Koichiro Den
2026-05-21 14:40   ` Frank Li
2026-05-21 15:15   ` sashiko-bot [this message]
2026-05-22  8:48     ` Koichiro Den
2026-05-21 14:21 ` [PATCH 3/4] dmaengine: dw-edma: Initialize IRQ data before requesting IRQs Koichiro Den
2026-05-21 14:44   ` Frank Li
2026-05-22  3:30     ` Koichiro Den
2026-05-21 15:58   ` sashiko-bot
2026-05-21 14:21 ` [PATCH 4/4] dmaengine: dw-edma: Add spinlock to protect DONE_INT_MASK and ABORT_INT_MASK Koichiro Den
2026-05-21 16:56   ` sashiko-bot
2026-05-22  8:22     ` Koichiro Den
2026-05-25  6:03 ` [PATCH 0/4] dmaengine: dw-edma: Fix probe paths and register races Koichiro Den
2026-06-08 12:13 ` (subset) " Vinod Koul

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=20260521151504.69BA61F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=den@valinux.co.jp \
    --cc=dmaengine@vger.kernel.org \
    --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