Once mem->bo is removed from the cache, it is likely to be freed.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: b80930a6fea075 ("anv: add support for VK_EXT_memory_budget")
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
if (mem->map)
anv_UnmapMemory(_device, _mem);
+ p_atomic_add(&pdevice->memory.heaps[mem->type->heapIndex].used,
+ -mem->bo->size);
+
anv_bo_cache_release(device, &device->bo_cache, mem->bo);
#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
AHardwareBuffer_release(mem->ahw);
#endif
- p_atomic_add(&pdevice->memory.heaps[mem->type->heapIndex].used,
- -mem->bo->size);
-
vk_free2(&device->alloc, pAllocator, mem);
}