Commit cabbdea1 authored by Daniil Dulov's avatar Daniil Dulov Committed by Alex Deucher

drm/amdkfd: Fix potential deallocation of previously deallocated memory.

Pointer mqd_mem_obj can be deallocated in kfd_gtt_sa_allocate().
The function then returns non-zero value, which causes the second deallocation.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: d1f8f0d1 ("drm/amdkfd: Move non-sdma mqd allocation out of init_mqd")
Signed-off-by: default avatarDaniil Dulov <d.dulov@aladdin.ru>
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6d99f3f4
...@@ -115,18 +115,19 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, ...@@ -115,18 +115,19 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd,
&(mqd_mem_obj->gtt_mem), &(mqd_mem_obj->gtt_mem),
&(mqd_mem_obj->gpu_addr), &(mqd_mem_obj->gpu_addr),
(void *)&(mqd_mem_obj->cpu_ptr), true); (void *)&(mqd_mem_obj->cpu_ptr), true);
if (retval) {
kfree(mqd_mem_obj);
return NULL;
}
} else { } else {
retval = kfd_gtt_sa_allocate(kfd, sizeof(struct v9_mqd), retval = kfd_gtt_sa_allocate(kfd, sizeof(struct v9_mqd),
&mqd_mem_obj); &mqd_mem_obj);
} if (retval)
return NULL;
if (retval) {
kfree(mqd_mem_obj);
return NULL;
} }
return mqd_mem_obj; return mqd_mem_obj;
} }
static void init_mqd(struct mqd_manager *mm, void **mqd, static void init_mqd(struct mqd_manager *mm, void **mqd,
......
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