diff options
author | Jason Ekstrand <[email protected]> | 2019-10-30 12:31:12 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-10-31 13:46:09 +0000 |
commit | 0ca0ad1252bbdc8e9fba5d3d89f8bc854ce355eb (patch) | |
tree | 3b355ff7ba0625afa5d3d2b9f28ddb41da7bef78 /src/intel/vulkan/anv_allocator.c | |
parent | b3c0b1b21880987d90bd5738736f2bd920f76b18 (diff) |
anv: Zero released anv_bo structs
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_allocator.c')
-rw-r--r-- | src/intel/vulkan/anv_allocator.c | 13 |
1 files changed, 12 insertions, 1 deletions
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 |