winsys/amdgpu: use alloca when using global_bo_list
authorMarek Olšák <marek.olsak@amd.com>
Thu, 12 Jul 2018 03:24:31 +0000 (23:24 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 16 Jul 2018 17:32:33 +0000 (13:32 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c

index 1aaa066731090de06e201c6ed4cba3fc4347c92e..ec164175dbc6613ca918be7c265c1bd6e2db18c3 100644 (file)
@@ -1300,14 +1300,7 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
       unsigned num = 0;
 
       simple_mtx_lock(&ws->global_bo_list_lock);
-
-      handles = malloc(sizeof(handles[0]) * ws->num_buffers);
-      if (!handles) {
-         simple_mtx_unlock(&ws->global_bo_list_lock);
-         amdgpu_cs_context_cleanup(cs);
-         cs->error_code = -ENOMEM;
-         return;
-      }
+      handles = alloca(sizeof(handles[0]) * ws->num_buffers);
 
       LIST_FOR_EACH_ENTRY(bo, &ws->global_bo_list, u.real.global_list_item) {
          assert(num < ws->num_buffers);
@@ -1316,7 +1309,6 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
 
       r = amdgpu_bo_list_create(ws->dev, ws->num_buffers,
                                 handles, NULL, &bo_list);
-      free(handles);
       simple_mtx_unlock(&ws->global_bo_list_lock);
       if (r) {
          fprintf(stderr, "amdgpu: buffer list creation failed (%d)\n", r);