mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-25 16:50:52 -04:00
drm/amdkfd: fix a memory leak in device_queue_manager_init()
If dqm->ops.initialize() fails, add deallocate_hiq_sdma_mqd()
to release the memory allocated by allocate_hiq_sdma_mqd().
Move deallocate_hiq_sdma_mqd() up to ensure proper function
visibility at the point of use.
Fixes: 11614c36bc ("drm/amdkfd: Allocate MQD trunk for HIQ and SDMA")
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Signed-off-by: Felix Kuehling <felix.kuehling@amd.com>
Reviewed-by: Oak Zeng <Oak.Zeng@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
d967509651
commit
b7cccc8286
@@ -2916,6 +2916,14 @@ static int allocate_hiq_sdma_mqd(struct device_queue_manager *dqm)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void deallocate_hiq_sdma_mqd(struct kfd_node *dev,
|
||||||
|
struct kfd_mem_obj *mqd)
|
||||||
|
{
|
||||||
|
WARN(!mqd, "No hiq sdma mqd trunk to free");
|
||||||
|
|
||||||
|
amdgpu_amdkfd_free_gtt_mem(dev->adev, &mqd->gtt_mem);
|
||||||
|
}
|
||||||
|
|
||||||
struct device_queue_manager *device_queue_manager_init(struct kfd_node *dev)
|
struct device_queue_manager *device_queue_manager_init(struct kfd_node *dev)
|
||||||
{
|
{
|
||||||
struct device_queue_manager *dqm;
|
struct device_queue_manager *dqm;
|
||||||
@@ -3041,19 +3049,14 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_node *dev)
|
|||||||
return dqm;
|
return dqm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dev->kfd->shared_resources.enable_mes)
|
||||||
|
deallocate_hiq_sdma_mqd(dev, &dqm->hiq_sdma_mqd);
|
||||||
|
|
||||||
out_free:
|
out_free:
|
||||||
kfree(dqm);
|
kfree(dqm);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deallocate_hiq_sdma_mqd(struct kfd_node *dev,
|
|
||||||
struct kfd_mem_obj *mqd)
|
|
||||||
{
|
|
||||||
WARN(!mqd, "No hiq sdma mqd trunk to free");
|
|
||||||
|
|
||||||
amdgpu_amdkfd_free_gtt_mem(dev->adev, &mqd->gtt_mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void device_queue_manager_uninit(struct device_queue_manager *dqm)
|
void device_queue_manager_uninit(struct device_queue_manager *dqm)
|
||||||
{
|
{
|
||||||
dqm->ops.stop(dqm);
|
dqm->ops.stop(dqm);
|
||||||
|
|||||||
Reference in New Issue
Block a user