[Beignet] [PATCH] Fix a bug for double free of enqueueNativeKernel.

junyan.he at inbox.com junyan.he at inbox.com
Thu Sep 29 10:05:26 UTC 2016


From: Junyan He <junyan.he at intel.com>

Signed-off-by: Junyan He <junyan.he at intel.com>
---
 src/cl_api_kernel.c | 3 +++
 src/cl_enqueue.c    | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/cl_api_kernel.c b/src/cl_api_kernel.c
index ef494e6..1fd687b 100644
--- a/src/cl_api_kernel.c
+++ b/src/cl_api_kernel.c
@@ -311,6 +311,9 @@ clEnqueueNativeKernel(cl_command_queue command_queue,
     data->offset = (size_t)num_mem_objects;
     data->const_ptr = new_args_mem_loc;
     data->user_func = user_func;
+    new_args = NULL;
+    new_mem_list = NULL;
+    new_args_mem_loc = NULL; // Event delete will free them.
 
     if (e_status == CL_COMPLETE) {
       // Sync mode, no need to queue event.
diff --git a/src/cl_enqueue.c b/src/cl_enqueue.c
index ac29ebe..29cf593 100644
--- a/src/cl_enqueue.c
+++ b/src/cl_enqueue.c
@@ -484,7 +484,6 @@ cl_enqueue_native_kernel(enqueue_data *data, cl_int status)
     cl_mem_unmap_auto(mem_list[i]);
   }
 
-  free(data->ptr);
 error:
   return err;
 }
-- 
2.7.4





More information about the Beignet mailing list