[Mesa-dev] [PATCH 2/2] clover: check clEnqueueMap* for map errors

Grigori Goronzy greg at chown.ath.cx
Thu May 28 01:10:20 PDT 2015


Mapping can fail, and this should be handled. Return the proper error
code and abort the associated event in this case.
---
 src/gallium/state_trackers/clover/api/transfer.cpp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/transfer.cpp b/src/gallium/state_trackers/clover/api/transfer.cpp
index 4986f53..275059c 100644
--- a/src/gallium/state_trackers/clover/api/transfer.cpp
+++ b/src/gallium/state_trackers/clover/api/transfer.cpp
@@ -699,11 +699,17 @@ clEnqueueMapBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
       map_resource_op(q, &mem, flags, blocking, obj_origin, region, &map));
 
    ret_object(rd_ev, hev);
-   ret_error(r_errcode, CL_SUCCESS);
 
    if (blocking)
       hev().wait();
 
+   if (!map) {
+      hev().abort(CL_MAP_FAILURE);
+      ret_error(r_errcode, CL_MAP_FAILURE);
+      return NULL;
+   }
+
+   ret_error(r_errcode, CL_SUCCESS);
    return map;
 
 } catch (error &e) {
@@ -734,11 +740,17 @@ clEnqueueMapImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
       map_resource_op(q, &img, flags, blocking, origin, region, &map));
 
    ret_object(rd_ev, hev);
-   ret_error(r_errcode, CL_SUCCESS);
 
    if (blocking)
       hev().wait();
 
+   if (!map) {
+      hev().abort(CL_MAP_FAILURE);
+      ret_error(r_errcode, CL_MAP_FAILURE);
+      return NULL;
+   }
+
+   ret_error(r_errcode, CL_SUCCESS);
    return map;
 
 } catch (error &e) {
-- 
1.9.1



More information about the mesa-dev mailing list