[Beignet] [PATCH 1/4] Runtime: fixed parameter error checking in cl create buffer.
Yang, Rong R
rong.r.yang at intel.com
Tue Nov 26 22:19:42 PST 2013
This patchset LGTM, thanks.
-----Original Message-----
From: beignet-bounces+rong.r.yang=intel.com at lists.freedesktop.org [mailto:beignet-bounces+rong.r.yang=intel.com at lists.freedesktop.org] On Behalf Of Zhigang Gong
Sent: Monday, November 25, 2013 1:11 PM
To: beignet at lists.freedesktop.org
Cc: Gong, Zhigang
Subject: [Beignet] [PATCH 1/4] Runtime: fixed parameter error checking in cl create buffer.
This patch can pass piglit test case cl-api-create-buffer.
Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
src/cl_mem.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/cl_mem.c b/src/cl_mem.c index 8c9f8a8..8639502 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -294,10 +294,30 @@ cl_mem_new_buffer(cl_context ctx,
cl_int err = CL_SUCCESS;
cl_mem mem = NULL;
+ if (UNLIKELY(sz == 0)) {
+ err = CL_INVALID_BUFFER_SIZE;
+ goto error;
+ }
+
+ if (UNLIKELY(((flags & CL_MEM_READ_WRITE)
+ && (flags & (CL_MEM_READ_ONLY | CL_MEM_WRITE_ONLY)))
+ || ((flags & CL_MEM_READ_ONLY) && (flags & (CL_MEM_WRITE_ONLY)))
+ || ((flags & CL_MEM_ALLOC_HOST_PTR) && (flags & CL_MEM_USE_HOST_PTR))
+ || ((flags & CL_MEM_COPY_HOST_PTR) && (flags & CL_MEM_USE_HOST_PTR))
+ || ((flags & (~(CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY
+ | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR
+ | CL_MEM_USE_HOST_PTR))) != 0))) {
+ err = CL_INVALID_VALUE;
+ goto error;
+ }
+
/* This flag is valid only if host_ptr is not NULL */
- if (UNLIKELY((flags & CL_MEM_COPY_HOST_PTR ||
- flags & CL_MEM_USE_HOST_PTR) &&
- data == NULL)) {
+ if (UNLIKELY((((flags & CL_MEM_COPY_HOST_PTR) ||
+ (flags & CL_MEM_USE_HOST_PTR)) &&
+ data == NULL))
+ || (!(flags & (CL_MEM_COPY_HOST_PTR
+ |CL_MEM_USE_HOST_PTR))
+ && (data != NULL))) {
err = CL_INVALID_HOST_PTR;
goto error;
}
--
1.7.9.5
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list