mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmaengine: idxd: Remove channel from list on registration failure
@ 2026-07-09  6:23 Ruoyu Wang
  2026-07-09 15:30 ` Dave Jiang
  2026-10-16 15:58 ` Frank Li
  0 siblings, 2 replies; 3+ messages in thread
From: Ruoyu Wang @ 2026-07-09  6:23 UTC (permalink / raw)
  To: dave.jiang, vkoul
  Cc: ashok.raj, fenghua.yu, dmaengine, linux-kernel, Ruoyu Wang

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: idxd: Remove channel from list on registration failure
  2026-07-09  6:23 [PATCH] dmaengine: idxd: Remove channel from list on registration failure Ruoyu Wang
@ 2026-07-09 15:30 ` Dave Jiang
  2026-10-16 15:58 ` Frank Li
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2026-07-09 15:30 UTC (permalink / raw)
  To: Ruoyu Wang, vkoul; +Cc: ashok.raj, fenghua.yu, dmaengine, linux-kernel



On 7/8/26 11:23 PM, Ruoyu Wang wrote:
> 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>

Reviewed-by: Dave Jiang <dave.jiang@intel.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;
>  	}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: idxd: Remove channel from list on registration failure
  2026-07-09  6:23 [PATCH] dmaengine: idxd: Remove channel from list on registration failure Ruoyu Wang
  2026-07-09 15:30 ` Dave Jiang
@ 2026-10-16 15:58 ` Frank Li
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2026-10-16 15:58 UTC (permalink / raw)
  To: Ruoyu Wang
  Cc: dave.jiang, vkoul, ashok.raj, fenghua.yu, dmaengine, linux-kernel

On Thu, Jul 09, 2026 at 02:23:03PM +0800, Ruoyu Wang wrote:
> 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>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-16 15:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-09  6:23 [PATCH] dmaengine: idxd: Remove channel from list on registration failure Ruoyu Wang
2026-07-09 15:30 ` Dave Jiang
2026-10-16 15:58 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®