mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmaengine: idxd: Free the minor number when cdev setup fails
@ 2026-09-10  7:48 SeungUk Nam
  2026-10-01 20:56 ` Frank Li
  2026-11-20 10:04 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: SeungUk Nam @ 2026-09-10  7:48 UTC (permalink / raw)
  To: Vinicius Costa Gomes, Vinod Koul
  Cc: Dave Jiang, Frank Li, dmaengine, linux-kernel, SeungUk Nam

idxd_wq_add_cdev() allocates a minor number from cdev_ctx->minor_ida for
the new struct idxd_cdev. When dev_set_name() or cdev_device_add()
fails, the error path calls put_device(), and the release callback
idxd_cdev_dev_release() only frees idxd_cdev, so the minor number is
never returned to the ida. Leaked numbers accumulate across bind/unbind
cycles, up to MINORMASK, for as long as the module stays loaded.

Free the minor number before put_device() drops the last reference on
that path.

Fixes: c311f5e92484 ("dmaengine: idxd: Fix freeing the allocated ida too late")
Signed-off-by: SeungUk Nam <tmddnr49449@gmail.com>
---

Found by code inspection; the error path was not exercised at runtime.

 drivers/dma/idxd/cdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
index 82b07cf942ef..f1af7f0d25d3 100644
--- a/drivers/dma/idxd/cdev.c
+++ b/drivers/dma/idxd/cdev.c
@@ -573,6 +573,7 @@ int idxd_wq_add_cdev(struct idxd_wq *wq)
 	return 0;
 
  err:
+	ida_free(&cdev_ctx->minor_ida, minor);
 	put_device(dev);
 	wq->idxd_cdev = NULL;
 	return rc;
-- 
2.34.1


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

* Re: [PATCH] dmaengine: idxd: Free the minor number when cdev setup fails
  2026-09-10  7:48 [PATCH] dmaengine: idxd: Free the minor number when cdev setup fails SeungUk Nam
@ 2026-10-01 20:56 ` Frank Li
  2026-11-20 10:04 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2026-10-01 20:56 UTC (permalink / raw)
  To: SeungUk Nam
  Cc: Vinicius Costa Gomes, Vinod Koul, Dave Jiang, Frank Li,
	dmaengine, linux-kernel

On Thu, Sep 10, 2026 at 04:48:32PM +0900, SeungUk Nam wrote:
> idxd_wq_add_cdev() allocates a minor number from cdev_ctx->minor_ida for
> the new struct idxd_cdev. When dev_set_name() or cdev_device_add()
> fails, the error path calls put_device(), and the release callback
> idxd_cdev_dev_release() only frees idxd_cdev, so the minor number is
> never returned to the ida. Leaked numbers accumulate across bind/unbind
> cycles, up to MINORMASK, for as long as the module stays loaded.
>
> Free the minor number before put_device() drops the last reference on
> that path.
>
> Fixes: c311f5e92484 ("dmaengine: idxd: Fix freeing the allocated ida too late")
> Signed-off-by: SeungUk Nam <tmddnr49449@gmail.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>
> Found by code inspection; the error path was not exercised at runtime.
>
>  drivers/dma/idxd/cdev.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
> index 82b07cf942ef..f1af7f0d25d3 100644
> --- a/drivers/dma/idxd/cdev.c
> +++ b/drivers/dma/idxd/cdev.c
> @@ -573,6 +573,7 @@ int idxd_wq_add_cdev(struct idxd_wq *wq)
>  	return 0;
>
>   err:
> +	ida_free(&cdev_ctx->minor_ida, minor);
>  	put_device(dev);
>  	wq->idxd_cdev = NULL;
>  	return rc;
> --
> 2.34.1
>

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

* Re: [PATCH] dmaengine: idxd: Free the minor number when cdev setup fails
  2026-09-10  7:48 [PATCH] dmaengine: idxd: Free the minor number when cdev setup fails SeungUk Nam
  2026-10-01 20:56 ` Frank Li
@ 2026-11-20 10:04 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2026-11-20 10:04 UTC (permalink / raw)
  To: Vinicius Costa Gomes, SeungUk Nam
  Cc: Dave Jiang, Frank Li, dmaengine, linux-kernel


On Thu, 10 Sep 2026 16:48:32 +0900, SeungUk Nam wrote:
> idxd_wq_add_cdev() allocates a minor number from cdev_ctx->minor_ida for
> the new struct idxd_cdev. When dev_set_name() or cdev_device_add()
> fails, the error path calls put_device(), and the release callback
> idxd_cdev_dev_release() only frees idxd_cdev, so the minor number is
> never returned to the ida. Leaked numbers accumulate across bind/unbind
> cycles, up to MINORMASK, for as long as the module stays loaded.
> 
> [...]

Applied, thanks!

[1/1] dmaengine: idxd: Free the minor number when cdev setup fails
      commit: 56cbd7f69ce6037738410a5c50efb7cacf52b0ae

Best regards,
-- 
~Vinod



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

end of thread, other threads:[~2026-11-20 10:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-10  7:48 [PATCH] dmaengine: idxd: Free the minor number when cdev setup fails SeungUk Nam
2026-10-01 20:56 ` Frank Li
2026-11-20 10:04 ` Vinod Koul

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®