diff --git a/hipamd/src/hip_mempool.cpp b/hipamd/src/hip_mempool.cpp index cc7ba10865..bb11708264 100644 --- a/hipamd/src/hip_mempool.cpp +++ b/hipamd/src/hip_mempool.cpp @@ -61,10 +61,10 @@ hipError_t hipMallocAsync(void** dev_ptr, size_t size, hipStream_t stream) { if ((dev_ptr == nullptr) || (size == 0) || (!hip::isValid(stream))) { HIP_RETURN(hipErrorInvalidValue); } - auto device = reinterpret_cast(stream)->GetDevice(); - auto mem_pool = device->GetCurrentMemoryPool(); auto hip_stream = (stream == nullptr) ? hip::getCurrentDevice()->GetNullStream() : reinterpret_cast(stream); + auto device = hip_stream->GetDevice(); + auto mem_pool = device->GetCurrentMemoryPool(); *dev_ptr = reinterpret_cast(mem_pool)->AllocateMemory(size, hip_stream); HIP_RETURN(hipSuccess); }