<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Jose Fonseca <jfonseca@vmware.com></div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> sroland@vmware.com <sroland@vmware.com><br>
<b>Sent:</b> Friday, September 6, 2019 03:13<br>
<b>To:</b> Jose Fonseca <jfonseca@vmware.com>; airlied@redhat.com <airlied@redhat.com>; mesa-dev@lists.freedesktop.org <mesa-dev@lists.freedesktop.org><br>
<b>Cc:</b> Roland Scheidegger <sroland@vmware.com><br>
<b>Subject:</b> [PATCH] llvmpipe: fix CALLOC vs. free mismatches</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">From: Roland Scheidegger <sroland@vmware.com><br>
<br>
Should fix some issues we're seeing. And use REALLOC instead of realloc.<br>
---<br>
 src/gallium/drivers/llvmpipe/lp_cs_tpool.c | 6 +++---<br>
 src/gallium/drivers/llvmpipe/lp_state_cs.c | 3 ++-<br>
 2 files changed, 5 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/llvmpipe/lp_cs_tpool.c b/src/gallium/drivers/llvmpipe/lp_cs_tpool.c<br>
index 04495727e1c..6f1b4e2ee55 100644<br>
--- a/src/gallium/drivers/llvmpipe/lp_cs_tpool.c<br>
+++ b/src/gallium/drivers/llvmpipe/lp_cs_tpool.c<br>
@@ -65,7 +65,7 @@ lp_cs_tpool_worker(void *data)<br>
          cnd_broadcast(&task->finish);<br>
    }<br>
    mtx_unlock(&pool->m);<br>
-   free(lmem.local_mem_ptr);<br>
+   FREE(lmem.local_mem_ptr);<br>
    return 0;<br>
 }<br>
 <br>
@@ -105,7 +105,7 @@ lp_cs_tpool_destroy(struct lp_cs_tpool *pool)<br>
 <br>
    cnd_destroy(&pool->new_work);<br>
    mtx_destroy(&pool->m);<br>
-   free(pool);<br>
+   FREE(pool);<br>
 }<br>
 <br>
 struct lp_cs_tpool_task *<br>
@@ -148,6 +148,6 @@ lp_cs_tpool_wait_for_task(struct lp_cs_tpool *pool,<br>
    mtx_unlock(&pool->m);<br>
 <br>
    cnd_destroy(&task->finish);<br>
-   free(task);<br>
+   FREE(task);<br>
    *task_handle = NULL;<br>
 }<br>
diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c<br>
index 1645a185cb2..a26cbf4df22 100644<br>
--- a/src/gallium/drivers/llvmpipe/lp_state_cs.c<br>
+++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c<br>
@@ -1123,8 +1123,9 @@ cs_exec_fn(void *init_data, int iter_idx, struct lp_cs_local_mem *lmem)<br>
    memset(&thread_data, 0, sizeof(thread_data));<br>
 <br>
    if (lmem->local_size < job_info->req_local_mem) {<br>
+      lmem->local_mem_ptr = REALLOC(lmem->local_mem_ptr, lmem->local_size,<br>
+                                    job_info->req_local_mem);<br>
       lmem->local_size = job_info->req_local_mem;<br>
-      lmem->local_mem_ptr = realloc(lmem->local_mem_ptr, lmem->local_size);<br>
    }<br>
    thread_data.shared = lmem->local_mem_ptr;<br>
 <br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>