From: Jason Ekstrand Date: Wed, 30 Oct 2019 17:31:12 +0000 (-0500) Subject: anv: Zero released anv_bo structs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0ca0ad1252bbdc8e9fba5d3d89f8bc854ce355eb;p=mesa.git anv: Zero released anv_bo structs Reviewed-by: Lionel Landwerlin --- diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index 5b7464a6056..bd9289c1876 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -1846,7 +1846,18 @@ anv_device_release_bo(struct anv_device *device, if (!bo->has_fixed_address) anv_vma_free(device, bo); - anv_gem_close(device, bo->gem_handle); + uint32_t gem_handle = bo->gem_handle; + + /* Memset the BO just in case. The refcount being zero should be enough to + * prevent someone from assuming the data is valid but it's safer to just + * stomp to zero just in case. We explicitly do this *before* we close the + * GEM handle to ensure that if anyone allocates something and gets the + * same GEM handle, the memset has already happen and won't stomp all over + * any data they may write in this BO. + */ + memset(bo, 0, sizeof(*bo)); + + anv_gem_close(device, gem_handle); /* Don't unlock until we've actually closed the BO. The whole point of * the BO cache is to ensure that we correctly handle races with creating