turnip: Initialize *memory on 0-sized alloc early exit.
authorEmma Anholt <emma@anholt.net>
Mon, 5 Dec 2022 22:52:07 +0000 (14:52 -0800)
committerMarge Bot <emma+marge@anholt.net>
Tue, 6 Dec 2022 16:59:59 +0000 (16:59 +0000)
Otherwise, making a CS using the memory will use the uninitialized .map
value (when checking the size of the CS in in begin's tu_cs_is_empty()
check), causing valgrind noise in
dEQP-VK.binding_model.descriptorset_random.sets4.dynindexed.ubolimitlow.sbolimitlow.sampledimghigh.lowimgsingletex.iublimitlow.nouab.vert.noia.0
(thanks to vi_info->vertexBindingDescriptionCount==0).

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20173>

src/freedreno/vulkan/tu_cs.c

index 0bfb8e3..e38ba96 100644 (file)
@@ -290,8 +290,14 @@ tu_cs_alloc(struct tu_cs *cs,
    assert(cs->mode == TU_CS_MODE_SUB_STREAM);
    assert(size && size <= 1024);
 
-   if (!count)
+   if (!count) {
+      /* If you allocated no memory, you'd better not use the iova for anything
+       * (but it's left aligned for sanity).
+       */
+      memory->map = NULL;
+      memory->iova = 0xdead0000;
       return VK_SUCCESS;
+   }
 
    /* TODO: smarter way to deal with alignment? */