[Mesa-stable] [PATCH] st/clover: Don't segfault on clCreateBuffer with null context

Aaron Watry awatry at gmail.com
Thu Apr 3 16:19:52 PDT 2014


This should fix a segfault in the case that you're not using ocl-icd.

If you're using ocl-icd, make sure your version is new enough or you'll get
the segfault before you even get to clover.

The null de-ref seems to have been introduced in 10.1, but earlier versions
have have also been affected in other ways.

CC: "10.1" <mesa-stable at lists.freedesktop.org>

Signed-off-by: Aaron Watry <awatry at gmail.com>
---
 src/gallium/state_trackers/clover/api/memory.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/state_trackers/clover/api/memory.cpp b/src/gallium/state_trackers/clover/api/memory.cpp
index 7ed2191..dad5ad3 100644
--- a/src/gallium/state_trackers/clover/api/memory.cpp
+++ b/src/gallium/state_trackers/clover/api/memory.cpp
@@ -32,6 +32,9 @@ clCreateBuffer(cl_context d_ctx, cl_mem_flags flags, size_t size,
                void *host_ptr, cl_int *r_errcode) try {
    auto &ctx = obj(d_ctx);
 
+   if (d_ctx == NULL)
+	   throw error(CL_INVALID_CONTEXT);
+
    if (bool(host_ptr) != bool(flags & (CL_MEM_USE_HOST_PTR |
                                        CL_MEM_COPY_HOST_PTR)))
       throw error(CL_INVALID_HOST_PTR);
-- 
1.8.3.2



More information about the mesa-stable mailing list