SWDEV-343168 - return invalidValue if totalsize is more than device's global memory.

Change-Id: Ie052b9b75c9813d040fc23959df4146af98b96ed


[ROCm/clr commit: 4aa1ffcc45]
This commit is contained in:
Jaydeep
2022-06-28 06:43:30 +00:00
کامیت شده توسط Jaydeepkumar Patel
والد c5f60e51ac
کامیت 01e9429c97
@@ -723,6 +723,11 @@ hipError_t ihipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t heigh
const amd::Image::Format imageFormat(*image_format);
//avoid size_t overflow for pitch calculation
if (width * imageFormat.getElementSize() > (std::numeric_limits<size_t>::max() - device->info().imagePitchAlignment_)) {
return hipErrorInvalidValue;
}
*pitch = amd::alignUp(width * imageFormat.getElementSize(), device->info().imagePitchAlignment_);
size_t sizeBytes = *pitch * height * depth;