diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp index 4fa5df210e..de97499a80 100644 --- a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp +++ b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp @@ -1254,12 +1254,17 @@ pal::Memory* Device::createBuffer(amd::Memory& owner, bool directAccess) const { } else if (owner.getMemFlags() & CL_MEM_USE_PERSISTENT_MEM_AMD) { // Attempt to allocate from persistent heap result = gpuMemory->create(Resource::Persistent); - // Disallow permanent map for Win7 only, since OS will move buffer to sysmem - if (IS_LINUX || + if (result) { + // Disallow permanent map for Win7 only, since OS will move buffer to sysmem + if (IS_LINUX || // Or Win10 (properties().gpuMemoryProperties.flags.supportPerSubmitMemRefs == false)) { - void* address = gpuMemory->map(nullptr); - CondLog(address == nullptr, "PAL failed lock of persistent memory!"); + void* address = gpuMemory->map(nullptr); + CondLog(address == nullptr, "PAL failed lock of persistent memory!"); + } + } else { + delete gpuMemory; + return nullptr; } } else if (directAccess || (type == Resource::Remote)) { // Check for system memory allocations