From 38b4f50f9cc03b85c2c49055fe4ee765f1be829b Mon Sep 17 00:00:00 2001 From: Anusha GodavarthySurya Date: Thu, 1 Dec 2022 14:59:01 +0000 Subject: [PATCH] SWDEV-371206, SWDEV-371163 - Fix hipGraphNodeGetEnabled/SetEnabled negative scenarios Change-Id: Icf4bcca743c2188ee89dbdc8eb32d9d727b95227 [ROCm/clr commit: ac0db17b5416f965bc3d71996062eb3581f75d9c] --- projects/clr/hipamd/src/hip_graph.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/src/hip_graph.cpp b/projects/clr/hipamd/src/hip_graph.cpp index c0995f9415..6a87a560f6 100644 --- a/projects/clr/hipamd/src/hip_graph.cpp +++ b/projects/clr/hipamd/src/hip_graph.cpp @@ -2187,13 +2187,18 @@ hipError_t hipGraphDebugDotPrint(hipGraph_t graph, const char* path, unsigned in hipError_t hipGraphNodeSetEnabled(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, unsigned int isEnabled) { HIP_INIT_API(hipGraphNodeSetEnabled, hGraphExec, hNode, isEnabled); - if (hGraphExec == nullptr || hNode == nullptr) { + if (hGraphExec == nullptr || hNode == nullptr || !hipGraphExec::isGraphExecValid(hGraphExec) || + !hipGraphNode::isNodeValid(hNode)) { HIP_RETURN(hipErrorInvalidValue); } hipGraphNode_t clonedNode = hGraphExec->GetClonedNode(hNode); if (clonedNode == nullptr) { HIP_RETURN(hipErrorInvalidValue); } + if (!(hNode->GetType() == hipGraphNodeTypeKernel || hNode->GetType() == hipGraphNodeTypeMemcpy || + hNode->GetType() == hipGraphNodeTypeMemset)) { + return HIP_RETURN(hipErrorInvalidValue); + } clonedNode->SetEnabled(isEnabled); HIP_RETURN(hipSuccess); } @@ -2201,13 +2206,18 @@ hipError_t hipGraphNodeSetEnabled(hipGraphExec_t hGraphExec, hipGraphNode_t hNod hipError_t hipGraphNodeGetEnabled(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, unsigned int* isEnabled) { HIP_INIT_API(hipGraphNodeGetEnabled, hGraphExec, hNode, isEnabled); - if (hGraphExec == nullptr || hNode == nullptr || isEnabled == nullptr) { + if (hGraphExec == nullptr || hNode == nullptr || isEnabled == nullptr || + !hipGraphExec::isGraphExecValid(hGraphExec) || !hipGraphNode::isNodeValid(hNode)) { HIP_RETURN(hipErrorInvalidValue); } hipGraphNode_t clonedNode = hGraphExec->GetClonedNode(hNode); if (clonedNode == nullptr) { HIP_RETURN(hipErrorInvalidValue); } + if (!(hNode->GetType() == hipGraphNodeTypeKernel || hNode->GetType() == hipGraphNodeTypeMemcpy || + hNode->GetType() == hipGraphNodeTypeMemset)) { + return HIP_RETURN(hipErrorInvalidValue); + } *isEnabled = clonedNode->GetEnabled(); HIP_RETURN(hipSuccess); }