From 95f603cc513c9fb33cfcf4558d0befe4d24f8448 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Sun, 18 Jan 2015 23:24:04 +0100 Subject: fosphor/cl: Fix overflow when querying local_mem size CL_DEVICE_LOCAL_MEM_SIZE is an unsigned long and can be quite large. Signed-off-by: Sylvain Munaut --- lib/fosphor/cl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/fosphor/cl.c b/lib/fosphor/cl.c index f939f0d..7658d39 100644 --- a/lib/fosphor/cl.c +++ b/lib/fosphor/cl.c @@ -61,7 +61,7 @@ struct fosphor_cl_features cl_device_type type; char vendor[128]; - int local_mem; + unsigned long local_mem; int flags; int wg_size; int wg_size_dim[2]; @@ -145,12 +145,10 @@ cl_device_query(cl_device_id dev_id, struct fosphor_cl_features *feat) return -1; /* Local memory size */ - err = clGetDeviceInfo(dev_id, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(cl_ulong), &lmem, NULL); + err = clGetDeviceInfo(dev_id, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(cl_ulong), &feat->local_mem, NULL); if (err != CL_SUCCESS) return -1; - feat->local_mem = lmem; - /* CL/GL extension */ err = clGetDeviceInfo(dev_id, CL_DEVICE_EXTENSIONS, sizeof(txt)-1, txt, NULL); if (err != CL_SUCCESS) -- cgit v1.2.3