diff options
author | Huang Rui <ray.huang@amd.com> | 2020-02-11 15:40:24 +0800 |
---|---|---|
committer | Huang Rui <ray.huang@amd.com> | 2020-02-12 19:52:37 +0800 |
commit | fca0849af3bf0682d75d0a11e52e76592c5f42ef (patch) | |
tree | 5b2ee143ce159901caf0a5feece56df4c1b3e3b4 | |
parent | d8731e9eec93494cc76e7ec5207d13338305fa98 (diff) | |
download | libdrm-fca0849af3bf0682d75d0a11e52e76592c5f42ef.tar.gz libdrm-fca0849af3bf0682d75d0a11e52e76592c5f42ef.tar.bz2 libdrm-fca0849af3bf0682d75d0a11e52e76592c5f42ef.zip |
amdgpu: use alloca for dependencies and sem_dependencies
Use alloca instead of malloc, then we don't need free them at the end of this
function.
Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r-- | amdgpu/amdgpu_cs.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 1bd974f7..aaa1f7b1 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -295,7 +295,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context, } if (ibs_request->number_of_dependencies) { - dependencies = malloc(sizeof(struct drm_amdgpu_cs_chunk_dep) * + dependencies = alloca(sizeof(struct drm_amdgpu_cs_chunk_dep) * ibs_request->number_of_dependencies); if (!dependencies) { r = -ENOMEM; @@ -326,7 +326,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context, LIST_FOR_EACH_ENTRY(sem, sem_list, list) sem_count++; if (sem_count) { - sem_dependencies = malloc(sizeof(struct drm_amdgpu_cs_chunk_dep) * sem_count); + sem_dependencies = alloca(sizeof(struct drm_amdgpu_cs_chunk_dep) * sem_count); if (!sem_dependencies) { r = -ENOMEM; goto error_unlock; @@ -363,8 +363,6 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context, context->last_seq[ibs_request->ip_type][ibs_request->ip_instance][ibs_request->ring] = ibs_request->seq_no; error_unlock: pthread_mutex_unlock(&context->sequence_mutex); - free(dependencies); - free(sem_dependencies); return r; } |