[Beignet] [PATCH] Add some pointer access check.

Pan, Xiuli xiuli.pan at intel.com
Wed Jan 11 09:02:34 UTC 2017


LGTM. Thanks.

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Yang Rong
Sent: Wednesday, January 11, 2017 6:16 PM
To: beignet at lists.freedesktop.org
Cc: Yang, Rong R <rong.r.yang at intel.com>
Subject: [Beignet] [PATCH] Add some pointer access check.

Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 backend/src/backend/gen_reg_allocation.cpp | 4 ++--
 src/cl_command_queue.c                     | 1 +
 src/cl_device_enqueue.c                    | 3 +++
 src/cl_utils.c                             | 2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/backend/src/backend/gen_reg_allocation.cpp b/backend/src/backend/gen_reg_allocation.cpp
index 68b7a85..d88b316 100644
--- a/backend/src/backend/gen_reg_allocation.cpp
+++ b/backend/src/backend/gen_reg_allocation.cpp
@@ -86,8 +86,8 @@ namespace gbe
     INLINE void getRegAttrib(ir::Register reg, uint32_t &regSize, ir::RegisterFamily *regFamily = NULL) const {
       // Note that byte vector registers use two bytes per byte (and can be
       // interleaved)
-      static const size_t familyVectorSize[] = {2,2,2,4,8};
-      static const size_t familyScalarSize[] = {2,2,2,4,8};
+      static const size_t familyVectorSize[] = {2,2,2,4,8,16,32};
+      static const size_t familyScalarSize[] = {2,2,2,4,8,16,32};
       using namespace ir;
       const bool isScalar = ctx.sel->isScalarReg(reg);
       const RegisterData regData = ctx.sel->getRegisterData(reg);
diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c
index aa371d0..368e148 100644
--- a/src/cl_command_queue.c
+++ b/src/cl_command_queue.c
@@ -64,6 +64,7 @@ cl_create_command_queue(cl_context ctx, cl_device_id device, cl_command_queue_pr
   cl_command_queue queue = cl_command_queue_new(ctx);
   if (queue == NULL) {
     *errcode_ret = CL_OUT_OF_HOST_MEMORY;
+    return NULL;
   }
 
   queue->props = properties;
diff --git a/src/cl_device_enqueue.c b/src/cl_device_enqueue.c
index 18cd7e1..b6932df 100644
--- a/src/cl_device_enqueue.c
+++ b/src/cl_device_enqueue.c
@@ -75,6 +75,7 @@ cl_device_enqueue_bind_buffer(cl_gpgpu gpgpu, cl_kernel ker, uint32_t *max_bti,
     }
 
     mem = cl_context_get_svm_from_ptr(ker->program->ctx, ker->device_enqueue_ptr);
+    assert(mem);
     cl_gpgpu_bind_buf(gpgpu, mem->bo, offset, 0, buf_size, *max_bti);
 
     cl_gpgpu_set_kernel(gpgpu, ker);
@@ -146,6 +147,7 @@ cl_device_enqueue_parse_result(cl_command_queue queue, cl_gpgpu gpgpu)
     type = ndrange_info->type;
     dim = (type & 0xf0) >> 4;
     type = type & 0xf;
+    assert(dim <= 2);
     for(i = 0; i <= dim; i++) {
       fixed_global_sz[i] = ndrange_info->global_work_size[i];
       if(type > 1)
@@ -161,6 +163,7 @@ cl_device_enqueue_parse_result(cl_command_queue queue, cl_gpgpu gpgpu)
 
     kernel_name = interp_program_get_device_enqueue_kernel_name(ker->program->opaque, block->index);
     child_ker = cl_program_create_kernel(ker->program, kernel_name, NULL);
+    assert(child_ker);
     cl_kernel_set_arg_svm_pointer(child_ker, 0, block);
     int index = 1;
     for(i=0; i<slm_size/sizeof(int); i++, index++) {
diff --git a/src/cl_utils.c b/src/cl_utils.c
index bc62feb..38de1ea 100644
--- a/src/cl_utils.c
+++ b/src/cl_utils.c
@@ -76,7 +76,7 @@ cl_get_info_helper(const void *src, size_t src_size, void *dst, size_t dst_size,
   if (dst && dst_size < src_size)
     return CL_INVALID_VALUE;
 
-  if (dst_size) {
+  if (dst && dst_size) {
     memcpy(dst, src, src_size);
   }
 
-- 
2.1.4

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list