From 67792dd858504bb3d50f2099effc47c3dc8a6eca Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Mon, 2 Jan 2023 11:12:52 +0000 Subject: [PATCH] SWDEV-374373 - Occupied size should be within range. Change-Id: I20e24c628c51154c2f8f36dca0a6fa4ead1ee6d0 --- hipamd/src/hip_memory.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index b3c8865380..116ecb103d 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -2760,6 +2760,14 @@ hipError_t ihipGraphMemsetParams_validate(const hipMemsetParams* pNodeParams) { if (pNodeParams->height <= 0) { return hipErrorInvalidValue; } + + amd::Memory *memObj = amd::MemObjMap::FindMemObj(pNodeParams->dst); + if (memObj != nullptr) { + if ((pNodeParams->pitch * pNodeParams->height) > memObj->getSize()) { + return hipErrorInvalidValue; + } + } + return hipSuccess; }