llvmpipe: fix CALLOC vs. free mismatches
authorRoland Scheidegger <sroland@vmware.com>
Fri, 6 Sep 2019 02:12:06 +0000 (04:12 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Fri, 6 Sep 2019 16:31:34 +0000 (18:31 +0200)
Should fix some issues we're seeing. And use REALLOC instead of realloc.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/drivers/llvmpipe/lp_cs_tpool.c
src/gallium/drivers/llvmpipe/lp_state_cs.c

index 04495727e1ccb90f02a0b63befa96856026e3846..6f1b4e2ee5536e55403e94f31b5e31f31d21bcc0 100644 (file)
@@ -65,7 +65,7 @@ lp_cs_tpool_worker(void *data)
          cnd_broadcast(&task->finish);
    }
    mtx_unlock(&pool->m);
-   free(lmem.local_mem_ptr);
+   FREE(lmem.local_mem_ptr);
    return 0;
 }
 
@@ -105,7 +105,7 @@ lp_cs_tpool_destroy(struct lp_cs_tpool *pool)
 
    cnd_destroy(&pool->new_work);
    mtx_destroy(&pool->m);
-   free(pool);
+   FREE(pool);
 }
 
 struct lp_cs_tpool_task *
@@ -148,6 +148,6 @@ lp_cs_tpool_wait_for_task(struct lp_cs_tpool *pool,
    mtx_unlock(&pool->m);
 
    cnd_destroy(&task->finish);
-   free(task);
+   FREE(task);
    *task_handle = NULL;
 }
index 1645a185cb26c0f350efbbfd7fd2b4cb5480c3d0..a26cbf4df227e759c5956a53979b5235e7538721 100644 (file)
@@ -1123,8 +1123,9 @@ cs_exec_fn(void *init_data, int iter_idx, struct lp_cs_local_mem *lmem)
    memset(&thread_data, 0, sizeof(thread_data));
 
    if (lmem->local_size < job_info->req_local_mem) {
+      lmem->local_mem_ptr = REALLOC(lmem->local_mem_ptr, lmem->local_size,
+                                    job_info->req_local_mem);
       lmem->local_size = job_info->req_local_mem;
-      lmem->local_mem_ptr = realloc(lmem->local_mem_ptr, lmem->local_size);
    }
    thread_data.shared = lmem->local_mem_ptr;