diff --git a/projects/clr/hipamd/api/hip/hip_memory.cpp b/projects/clr/hipamd/api/hip/hip_memory.cpp index d2cb3b7d8c..d4380eee0b 100644 --- a/projects/clr/hipamd/api/hip/hip_memory.cpp +++ b/projects/clr/hipamd/api/hip/hip_memory.cpp @@ -1299,7 +1299,6 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void size_t offset = 0; amd::Memory* memObj = getMemoryObject(ptr, offset); - amd::Context &memObjCtx = memObj->getContext(); int device = 0; if (memObj != nullptr) { @@ -1308,6 +1307,8 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void attributes->devicePointer = memObj->getSvmPtr(); attributes->isManaged = 0; attributes->allocationFlags = memObj->getMemFlags(); + + amd::Context &memObjCtx = memObj->getContext(); for (auto& ctx : g_devices) { ++device; if (*ctx == memObjCtx) {