Do not create buffer when size is too big.

Resolves: NEO-3131
Change-Id: Icd37e7bc62719be5956b6a9435ab2fe7e0962c00
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2019-05-24 13:37:42 +02:00
committed by sys_ocldev
parent b98b51b0d9
commit 7830be3090
2 changed files with 26 additions and 7 deletions

View File

@@ -82,7 +82,14 @@ void Buffer::validateInputAndCreateBuffer(cl_context &context,
void *hostPtr,
cl_int &retVal,
cl_mem &buffer) {
if (size == 0) {
Context *pContext = nullptr;
retVal = validateObjects(WithCastToInternal(context, &pContext));
if (retVal != CL_SUCCESS) {
return;
}
auto pDevice = pContext->getDevice(0);
if (size == 0 || size > pDevice->getDeviceInfo().maxMemAllocSize) {
retVal = CL_INVALID_BUFFER_SIZE;
return;
}
@@ -99,12 +106,6 @@ void Buffer::validateInputAndCreateBuffer(cl_context &context,
return;
}
Context *pContext = nullptr;
retVal = validateObjects(WithCastToInternal(context, &pContext));
if (retVal != CL_SUCCESS) {
return;
}
// create the buffer
buffer = create(pContext, properties, size, hostPtr, retVal);
}