diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index 98ec3f2bf8..f07977772b 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -101,7 +101,10 @@ hipError_t ihipFree(void *ptr) } } else { // Wait on the device, associated with the current memory object - hip::getNullStream(memory_object->getContext())->finish(); + amd::HostQueue* queue = hip::getNullStream(memory_object->getContext()); + if (queue != nullptr) { + queue->finish(); + } deviceID = hip::getDeviceID(memory_object->getContext()); } hip::Stream::syncNonBlockingStreams(deviceID); diff --git a/hipamd/src/hip_stream.cpp b/hipamd/src/hip_stream.cpp index 84d6f60e9a..a8b8b9138c 100644 --- a/hipamd/src/hip_stream.cpp +++ b/hipamd/src/hip_stream.cpp @@ -110,7 +110,9 @@ bool Stream::Create() { queue->vdev()->profilerAttach(isProfilerAttached); device_->SaveQueue(queue); } else if (queue != nullptr) { - queue->release(); + // Queue creation has failed, and virtual device associated with the queue may not be created. + // Just need to delete the queue instance. + delete queue; } return result;