Commit e73390d1 authored by Oak Zeng's avatar Oak Zeng Committed by Alex Deucher

drm/amdkfd: Fix a potential memory leak

Free mqd_mem_obj it GTT buffer allocation for MQD+control stack fails.
Signed-off-by: default avatarOak Zeng <ozeng@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 11614c36
...@@ -76,6 +76,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -76,6 +76,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
struct v9_mqd *m; struct v9_mqd *m;
struct kfd_dev *kfd = mm->dev; struct kfd_dev *kfd = mm->dev;
*mqd_mem_obj = NULL;
/* From V9, for CWSR, the control stack is located on the next page /* From V9, for CWSR, the control stack is located on the next page
* boundary after the mqd, we will use the gtt allocation function * boundary after the mqd, we will use the gtt allocation function
* instead of sub-allocation function. * instead of sub-allocation function.
...@@ -93,8 +94,10 @@ static int init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -93,8 +94,10 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
} else } else
retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct v9_mqd), retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct v9_mqd),
mqd_mem_obj); mqd_mem_obj);
if (retval != 0) if (retval) {
kfree(*mqd_mem_obj);
return -ENOMEM; return -ENOMEM;
}
m = (struct v9_mqd *) (*mqd_mem_obj)->cpu_ptr; m = (struct v9_mqd *) (*mqd_mem_obj)->cpu_ptr;
addr = (*mqd_mem_obj)->gpu_addr; addr = (*mqd_mem_obj)->gpu_addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment