From 566cd820ac991d7ad02077c963736b23a36f386f Mon Sep 17 00:00:00 2001 From: Payam Date: Thu, 10 Mar 2022 21:13:20 -0500 Subject: [PATCH] SWDEV-315033,SWDEV-315028 - adding null checks for graph Change-Id: I9cbea5ea9ff59d7960ae11dfd73d5a744981495f [ROCm/clr commit: 6a48e430d0487d63895691b99ffde0e30c4cf74d] --- projects/clr/hipamd/src/hip_graph.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/clr/hipamd/src/hip_graph.cpp b/projects/clr/hipamd/src/hip_graph.cpp index d0ba5573a0..ba6f187dc0 100644 --- a/projects/clr/hipamd/src/hip_graph.cpp +++ b/projects/clr/hipamd/src/hip_graph.cpp @@ -1175,9 +1175,14 @@ hipError_t hipGraphAddDependencies(hipGraph_t graph, const hipGraphNode_t* from, } for (size_t i = 0; i < numDependencies; i++) { // When the same node is specified for both from and to - if (from[i] == to[i]) { + if (from[i] == nullptr || to[i] == nullptr || from[i] == to[i] || + // making sure the nodes blong to the graph + to[i]->GetParentGraph() != graph || from[i]->GetParentGraph() != graph) { HIP_RETURN(hipErrorInvalidValue); } + } + + for (size_t i = 0; i < numDependencies; i++) { // When the same edge added from->to return invalid value const std::vector& edges = from[i]->GetEdges(); for (auto edge : edges) {