radv: fix access to uninitialized radeon_bo_metadata
authorSimon Ser <contact@emersion.fr>
Thu, 3 Dec 2020 15:03:15 +0000 (16:03 +0100)
committerMarge Bot <eric+marge@anholt.net>
Mon, 14 Dec 2020 14:59:49 +0000 (14:59 +0000)
If the image tiling is set to VK_IMAGE_TILING_LINEAR,
buffer_set_metadata will read an uninitialized radeon_bo_metadata.

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: d5fd8cd46eee ("radv: Allow non-dedicated linear images and buffer.")
Cc: mesa-stable
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7898>

src/amd/vulkan/radv_device.c

index a403243..4e79e04 100644 (file)
@@ -5145,9 +5145,8 @@ bool radv_get_memory_fd(struct radv_device *device,
 {
        struct radeon_bo_metadata metadata;
 
-       if (memory->image) {
-               if (memory->image->tiling != VK_IMAGE_TILING_LINEAR)
-                       radv_init_metadata(device, memory->image, &metadata);
+       if (memory->image && memory->image->tiling != VK_IMAGE_TILING_LINEAR) {
+               radv_init_metadata(device, memory->image, &metadata);
                device->ws->buffer_set_metadata(memory->bo, &metadata);
        }