Module: Mesa
Branch: main
Commit: 8747715aecea73fa932d11a30188aae2b353cdb4
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8747715aecea73fa932d11a30188aae2b353cdb4

Author: Mike Blumenkrantz <[email protected]>
Date:   Tue Jan 25 11:25:24 2022 -0500

zink: reorder fbfetch flag-setting to avoid null deref

this avoids dereferencing pg->dd which is allocated a few lines later

Fixes: 417477f60ed ("zink: always use lazy (non-push) updating for fbfetch 
descriptors")

fixes (radv):
dEQP-GLES31.functional.blend_equation_advanced.basic.multiply

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14718>

---

 src/gallium/drivers/zink/zink_descriptors_lazy.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_descriptors_lazy.c 
b/src/gallium/drivers/zink/zink_descriptors_lazy.c
index 74dad9811b9..3c15ab9fd2d 100644
--- a/src/gallium/drivers/zink/zink_descriptors_lazy.c
+++ b/src/gallium/drivers/zink/zink_descriptors_lazy.c
@@ -161,20 +161,20 @@ zink_descriptor_program_init_lazy(struct zink_context 
*ctx, struct zink_program
    struct zink_shader **stages;
    if (pg->is_compute)
       stages = &((struct zink_compute_program*)pg)->shader;
-   else {
+   else
       stages = ((struct zink_gfx_program*)pg)->shaders;
-      if (stages[PIPE_SHADER_FRAGMENT]->nir->info.fs.uses_fbfetch_output) {
-         zink_descriptor_util_init_fbfetch(ctx);
-         push_count = 1;
-         pg->dd->fbfetch = true;
-      }
-   }
 
    if (!pg->dd)
       pg->dd = (void*)rzalloc(pg, struct zink_program_descriptor_data);
    if (!pg->dd)
       return false;
 
+   if (!pg->is_compute && 
stages[PIPE_SHADER_FRAGMENT]->nir->info.fs.uses_fbfetch_output) {
+      zink_descriptor_util_init_fbfetch(ctx);
+      push_count = 1;
+      pg->dd->fbfetch = true;
+   }
+
    unsigned entry_idx[ZINK_DESCRIPTOR_TYPES] = {0};
 
    unsigned num_shaders = pg->is_compute ? 1 : ZINK_SHADER_COUNT;

Reply via email to