Re: [PATCH] drm/amdkfd: fix a memory leak in device_queue_manager_init()

From: Kuehling, Felix
Date: Mon Jan 05 2026 - 14:00:07 EST


On 2026-01-04 08:15, Haoxiang Li wrote:
If dqm->ops.initialize() fails, add deallocate_hiq_sdma_mqd()
to release the memory allocated by allocate_hiq_sdma_mqd().

Signed-off-by: Haoxiang Li <lihaoxiang@xxxxxxxxxxxxxxxx>
---
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index d7a2e7178ea9..58a8d90c1533 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -3042,6 +3042,9 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_node *dev)
return dqm;
}
+ if (!dev->kfd->shared_resources.enable_mes)
+ deallocate_hiq_sdma_mqd(dev, &dqm->hiq_sdma_mqd);
+

I thing the idea is right. But see the report from the kernel test robot. Either move deallocate_hiq_sdma_mqd up or add a forward declaration.

With that fixed, the patch is

Reviewed-by: Felix Kuehling <felix.kuehling@xxxxxxx>

If you send an updated patch, I'll apply it to amd-staging-drm-next.

Thanks,
  Felix


out_free:
kfree(dqm);
return NULL;