summaryrefslogtreecommitdiff
path: root/src/cl_mem.c
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@intel.com>2015-02-06 17:48:15 +0800
committerZhigang Gong <zhigang.gong@intel.com>2015-02-09 09:44:47 +0800
commitc145a2d8a16db7b3fe1fe30f4c2778a77173c835 (patch)
tree5cbe719298fc1d8b1587a1796873d49a311d5302 /src/cl_mem.c
parente953dbb1ec80e6939100c9b124a5e737fc027983 (diff)
downloadbeignet-c145a2d8a16db7b3fe1fe30f4c2778a77173c835.tar.gz
runtime: don't free the host_ptr for a subbuffer.
When the buffer has CL_MEM_ALLOC_HOST_PTR, the runtime need to free the host_ptr at destructor. But if the buffer is a subbuffer, then its host ptr is not allocated by itself, we should not free it here. Otherwise, it may cause some weird errors such as: "corrupted double-linked list..". Signed-off-by: Zhigang Gong <zhigang.gong@intel.com> Reviewed-by: "Guo, Yejun" <yejun.guo@intel.com>
Diffstat (limited to 'src/cl_mem.c')
-rw-r--r--src/cl_mem.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cl_mem.c b/src/cl_mem.c
index e91d6080..51d60558 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -1128,7 +1128,9 @@ cl_mem_delete(cl_mem mem)
cl_buffer_unreference(mem->bo);
}
- if (mem->is_userptr && (mem->flags & CL_MEM_ALLOC_HOST_PTR))
+ if (mem->is_userptr &&
+ (mem->flags & CL_MEM_ALLOC_HOST_PTR) &&
+ (mem->type != CL_MEM_SUBBUFFER_TYPE))
cl_free(mem->host_ptr);
cl_free(mem);