[Beignet] [PATCH 1/2] Runtime: Add NULL pointer check in clGetKernelArgInfo

junyan.he at inbox.com junyan.he at inbox.com
Sun Sep 6 03:45:07 PDT 2015


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

There is no NULL pointer check for kernel->program->build_opts.
This will cause utest test_get_arg_info crash.
In fact, we will add -cl-kernel-arg-info flag for compiling
ever time, and so the arg info is always avaible.
But some test case deliberately unset this flag and expect the ERR
return value, so we really need a check here.

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

diff --git a/src/cl_api.c b/src/cl_api.c
index d1d7a09..dbbcbb0 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -1251,7 +1251,8 @@ cl_int clGetKernelArgInfo(cl_kernel kernel, cl_uint arg_index, cl_kernel_arg_inf
   cl_int err = CL_SUCCESS;
   CHECK_KERNEL(kernel);
 
-  if(strstr(kernel->program->build_opts,"-cl-kernel-arg-info") == NULL ) {
+  if(kernel->program->build_opts == NULL ||
+        strstr(kernel->program->build_opts,"-cl-kernel-arg-info") == NULL ) {
     err = CL_KERNEL_ARG_INFO_NOT_AVAILABLE;
     goto error;
   }
-- 
1.9.1



More information about the Beignet mailing list