From 5053dbe40e528f0bb727bec87a1682e0eb8f5cc8 Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Mon, 5 Sep 2022 09:47:42 +0000 Subject: [PATCH] SWDEV-351054 - Move validation for w & h to hipMemAllocPitch. Change-Id: Ia624fc99e797baf88dc029d7e36bb80df1bd7d12 [ROCm/clr commit: e5dff9a140da954e501db6190e1dfa683c263921] --- projects/clr/hipamd/src/hip_memory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index 494ba8ddcc..4be5e43e1c 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -753,9 +753,6 @@ hipError_t ihipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t heigh hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) { HIP_INIT_API(hipMallocPitch, ptr, pitch, width, height); CHECK_STREAM_CAPTURE_SUPPORTED(); - if (width == 0 || height == 0) { - HIP_RETURN(hipErrorInvalidValue); - } HIP_RETURN(ihipMallocPitch(ptr, pitch, width, height, 1), (ptr != nullptr)? *ptr : nullptr); } @@ -2876,6 +2873,9 @@ hipError_t hipMemAllocPitch(hipDeviceptr_t* dptr, size_t* pitch, size_t widthInB size_t height, unsigned int elementSizeBytes) { HIP_INIT_API(hipMemAllocPitch, dptr, pitch, widthInBytes, height, elementSizeBytes); CHECK_STREAM_CAPTURE_SUPPORTED(); + if (widthInBytes == 0 || height == 0) { + HIP_RETURN(hipErrorInvalidValue); + } if (elementSizeBytes != 4 && elementSizeBytes != 8 && elementSizeBytes != 16) { HIP_RETURN(hipErrorInvalidValue); }