diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp index db6a71dc19..36d49cf5dd 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp @@ -372,6 +372,7 @@ bool Load() { if (hsaKmtOpenKFD() != HSAKMT_STATUS_SUCCESS) { return false; } + MAKE_NAMED_SCOPE_GUARD(kfd, [&]() { hsaKmtCloseKFD(); }); // Register runtime and optionally enable the debugger HSAKMT_STATUS err = @@ -382,6 +383,7 @@ bool Load() { // Build topology table. BuildTopology(); + kfd.Dismiss(); return true; }