From 01a5ddebe6d41f66ded98c27fb5b2133c3ffcf10 Mon Sep 17 00:00:00 2001 From: Rakesh Roy Date: Wed, 18 May 2022 23:25:14 +0530 Subject: [PATCH] SWDEV-337119 - Validate width isn't exceeding either dpitch or spitch in ihipMemcpy2D Change-Id: I8ac68e033762616a42585b26f0b3aa5bbb29ce9c --- hipamd/src/hip_memory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index d2866fff49..a824e65914 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -2031,12 +2031,12 @@ hipError_t ihipMemcpyParam2D(const hip_Memcpy2D* pCopy, hipError_t ihipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream, bool isAsync = false) { hip_Memcpy2D desc = {}; - if (spitch == 0 || dpitch == 0) { - return hipErrorUnknown; - } - if (width == 0 || height == 0) { + if ((width == 0) || (height == 0)) { return hipSuccess; } + if ((width > dpitch) || (width > spitch)) { + return hipErrorInvalidPitchValue; + } desc.srcXInBytes = 0; desc.srcY = 0;