diff --git a/hipamd/rocclr/hip_memory.cpp b/hipamd/rocclr/hip_memory.cpp index 8fd9b05cdb..02e973eaec 100755 --- a/hipamd/rocclr/hip_memory.cpp +++ b/hipamd/rocclr/hip_memory.cpp @@ -1970,7 +1970,7 @@ hipError_t hipIpcOpenMemHandle(void** dev_ptr, hipIpcMemHandle_t handle, unsigne amd::Device* device = nullptr; ihipIpcMemHandle_t* ihandle = nullptr; - if (dev_ptr == nullptr) { + if (dev_ptr == nullptr || flags != hipIpcMemLazyEnablePeerAccess) { HIP_RETURN(hipErrorInvalidValue); } @@ -1978,6 +1978,10 @@ hipError_t hipIpcOpenMemHandle(void** dev_ptr, hipIpcMemHandle_t handle, unsigne device = hip::getCurrentDevice()->devices()[0]; ihandle = reinterpret_cast(&handle); + if (ihandle->psize == 0) { + HIP_RETURN(hipErrorInvalidValue); + } + if(!device->IpcAttach(&(ihandle->ipc_handle), ihandle->psize, flags, dev_ptr)) { DevLogPrintfError("cannot attach ipc_handle: with ipc_size: %u flags: %u", ihandle->psize, flags); HIP_RETURN(hipErrorInvalidDevicePointer);