This is a note to let you know that I've just added the patch titled dmaengine: idxd: fix resource leak on dmaengine driver disable to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: dmaengine-idxd-fix-resource-leak-on-dmaengine-driver.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 2e73d5e4921aa77b4a35a2ef1a154bc8e721d4df Author: Dave Jiang <dave.jiang@xxxxxxxxx> Date: Mon Oct 25 08:01:04 2021 -0700 dmaengine: idxd: fix resource leak on dmaengine driver disable [ Upstream commit a3e340c1574b6679f5b333221284d0959095da52 ] The wq resources needs to be released before the kernel type is reset by __drv_disable_wq(). With dma channels unregistered and wq quiesced, all the wq resources for dmaengine can be freed. There is no need to wait until wq is disabled. With the wq->type being reset to "unknown", the driver is skipping the freeing of the resources. Fixes: 0cda4f6986a3 ("dmaengine: idxd: create dmaengine driver for wq 'device'") Reported-by: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx> Tested-by: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx> Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx> Link: https://lore.kernel.org/r/163517405099.3484556.12521975053711345244.stgit@xxxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Vinod Koul <vkoul@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/dma/idxd/dma.c b/drivers/dma/idxd/dma.c index b90b085d18cff..c39e9483206ad 100644 --- a/drivers/dma/idxd/dma.c +++ b/drivers/dma/idxd/dma.c @@ -329,10 +329,9 @@ static void idxd_dmaengine_drv_remove(struct idxd_dev *idxd_dev) mutex_lock(&wq->wq_lock); idxd_wq_quiesce(wq); idxd_unregister_dma_channel(wq); + idxd_wq_free_resources(wq); __drv_disable_wq(wq); percpu_ref_exit(&wq->wq_active); - idxd_wq_free_resources(wq); - wq->type = IDXD_WQT_NONE; mutex_unlock(&wq->wq_lock); }