[Mesa-dev] [PATCH] llvmpipe: fix CALLOC vs. free mismatches

Jose Fonseca jfonseca at vmware.com
Fri Sep 6 06:12:23 UTC 2019


Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

________________________________
From: sroland at vmware.com <sroland at vmware.com>
Sent: Friday, September 6, 2019 03:13
To: Jose Fonseca <jfonseca at vmware.com>; airlied at redhat.com <airlied at redhat.com>; mesa-dev at lists.freedesktop.org <mesa-dev at lists.freedesktop.org>
Cc: Roland Scheidegger <sroland at vmware.com>
Subject: [PATCH] llvmpipe: fix CALLOC vs. free mismatches

From: Roland Scheidegger <sroland at vmware.com>

Should fix some issues we're seeing. And use REALLOC instead of realloc.
---
 src/gallium/drivers/llvmpipe/lp_cs_tpool.c | 6 +++---
 src/gallium/drivers/llvmpipe/lp_state_cs.c | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_cs_tpool.c b/src/gallium/drivers/llvmpipe/lp_cs_tpool.c
index 04495727e1c..6f1b4e2ee55 100644
--- a/src/gallium/drivers/llvmpipe/lp_cs_tpool.c
+++ b/src/gallium/drivers/llvmpipe/lp_cs_tpool.c
@@ -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;
 }
diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c
index 1645a185cb2..a26cbf4df22 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_cs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c
@@ -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;

--
2.17.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190906/537da43a/attachment.html>


More information about the mesa-dev mailing list