From f9574cd645ce07d409861a4b960f6628683dc203 Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Sun, 25 Dec 2022 13:56:58 +0000 Subject: [PATCH] SWDEV-374372 - Return invalid value if pitch is less than width in bytes. Change-Id: I33806d747cd344250d02e217de8e9b6d5a7f83c1 [ROCm/clr commit: 7c32f66e67af89b50d41739427f882319f6737f5] --- projects/clr/hipamd/src/hip_graph.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/projects/clr/hipamd/src/hip_graph.cpp b/projects/clr/hipamd/src/hip_graph.cpp index a8e5419ff6..edeb1a6126 100644 --- a/projects/clr/hipamd/src/hip_graph.cpp +++ b/projects/clr/hipamd/src/hip_graph.cpp @@ -134,7 +134,10 @@ hipError_t ihipGraphAddMemsetNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, ihipMemset_validate(pMemsetParams->dst, pMemsetParams->value, pMemsetParams->elementSize, pMemsetParams->width * pMemsetParams->elementSize); } else { - auto sizeBytes = pMemsetParams->width * pMemsetParams->height * 1; + if (pMemsetParams->pitch < (pMemsetParams->width * pMemsetParams->elementSize)) { + return hipErrorInvalidValue; + } + auto sizeBytes = pMemsetParams->width * pMemsetParams->height * pMemsetParams->elementSize * 1; status = ihipMemset3D_validate( {pMemsetParams->dst, pMemsetParams->pitch, pMemsetParams->width, pMemsetParams->height}, pMemsetParams->value, {pMemsetParams->width, pMemsetParams->height, 1}, sizeBytes); @@ -1363,6 +1366,9 @@ hipError_t hipGraphMemsetNodeSetParams(hipGraphNode_t node, const hipMemsetParam if (node == nullptr || pNodeParams == nullptr) { HIP_RETURN(hipErrorInvalidValue); } + if (pNodeParams->height > 1 && pNodeParams->pitch < (pNodeParams->width * pNodeParams->elementSize)) { + return hipErrorInvalidValue; + } HIP_RETURN(reinterpret_cast(node)->SetParams(pNodeParams)); }