DMA Engine development
 help / color / mirror / Atom feed
From: Ruoyu Wang <ruoyuw560@gmail.com>
To: dave.jiang@intel.com, vkoul@kernel.org
Cc: ashok.raj@intel.com, fenghua.yu@intel.com,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ruoyu Wang <ruoyuw560@gmail.com>
Subject: [PATCH] dmaengine: idxd: Remove channel from list on registration failure
Date: Thu,  9 Jul 2026 14:23:03 +0800	[thread overview]
Message-ID: <20260709062303.4167624-1-ruoyuw560@gmail.com> (raw)

idxd_register_dma_channel() links the channel before registering it.
If dma_async_device_channel_register() fails after that, the error path
frees idxd_chan while chan->device_node remains on dma->channels.

The DMA device can therefore retain a channel list entry that points into
freed idxd_chan memory. Remove the channel from dma->channels before
freeing idxd_chan on the registration failure path, matching the driver's
normal unregister path.

A static analysis checker reported the stale list entry, and manual
source review confirmed the registration failure path.

Fixes: 397862855619 ("dmaengine: idxd: fix dma device lifetime")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/dma/idxd/dma.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/idxd/dma.c b/drivers/dma/idxd/dma.c
index 9937b671f6376..f2c03f3cf1925 100644
--- a/drivers/dma/idxd/dma.c
+++ b/drivers/dma/idxd/dma.c
@@ -289,6 +289,7 @@ static int idxd_register_dma_channel(struct idxd_wq *wq)
 
 	rc = dma_async_device_channel_register(dma, chan, NULL);
 	if (rc < 0) {
+		list_del(&chan->device_node);
 		kfree(idxd_chan);
 		return rc;
 	}
-- 
2.51.0


             reply	other threads:[~2026-07-09  6:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  6:23 Ruoyu Wang [this message]
2026-07-09  6:37 ` [PATCH] dmaengine: idxd: Remove channel from list on registration failure sashiko-bot
2026-07-09 15:30 ` Dave Jiang

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=20260709062303.4167624-1-ruoyuw560@gmail.com \
    --to=ruoyuw560@gmail.com \
    --cc=ashok.raj@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fenghua.yu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --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