Module: Mesa
Branch: staging/21.1
Commit: 229948d8e59a90da1adaad57fe4ae8f36cd88334
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=229948d8e59a90da1adaad57fe4ae8f36cd88334

Author: Erik Faye-Lund <[email protected]>
Date:   Tue May  4 13:04:48 2021 +0200

gallium/u_vbuf: avoid dereferencing NULL pointer

When I last time fixed this, I missed that continuing here would make us
leak pointers in the translate state, which is what made this avoid a
crash in the first place.

That's not great, we need to set *some* pointer in this case. The
obvious option would be NULL, but that means that the translate-code
also needs to support NULL-pointers here.

Instead, let's point to a small, static buffer that contains enough
zero-data for the largest possible vertex attribute. This avoids having
to add more NULL-checks.

Fixes: a8e8204b186 ("gallium/u_vbuf: support NULL-resources")
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7773>
(cherry picked from commit a2d091694f8cf30f7f8a15d9c26712d4e56eaa6c)

---

 .gitlab-ci/windows/quick_gl.txt                       | 5 ++---
 .pick_status.json                                     | 2 +-
 src/gallium/auxiliary/util/u_vbuf.c                   | 5 ++++-
 src/gallium/drivers/zink/ci/piglit-zink-lvp-fails.txt | 1 -
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci/windows/quick_gl.txt b/.gitlab-ci/windows/quick_gl.txt
index 816ae879d61..89a582ead2c 100644
--- a/.gitlab-ci/windows/quick_gl.txt
+++ b/.gitlab-ci/windows/quick_gl.txt
@@ -149,7 +149,6 @@ spec/!opengl 1.1/polygon-mode-offset/config 4: expected 
white pixel on left edge
 spec/!opengl 1.1/polygon-mode-offset/config 4: expected white pixel on right 
edge: fail
 spec/!opengl 1.1/polygon-mode-offset/config 4: expected white pixel on top 
edge: fail
 spec/!opengl 1.1/polygon-offset: fail
-spec/!opengl 1.1/ppgtt_memory_alignment: fail
 spec/!opengl 1.1/read-front clear-front-first samples=16: skip
 spec/!opengl 1.1/read-front clear-front-first samples=2: skip
 spec/!opengl 1.1/read-front clear-front-first samples=32: skip
@@ -4754,8 +4753,8 @@ wgl/wgl-sanity: skip
 summary:
        name:  results
        ----  --------
-       pass:    13298
-       fail:      539
+       pass:    13299
+       fail:      538
       crash:       68
        skip:     4126
     timeout:        0
diff --git a/.pick_status.json b/.pick_status.json
index 48eb24179c3..727d16d4eda 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -67,7 +67,7 @@
         "description": "gallium/u_vbuf: avoid dereferencing NULL pointer",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "a8e8204b18697e8f45643abdd5b32b6c8f3659ac"
     },
diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index 89fd5c9baa1..64639b56a11 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -437,8 +437,11 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct 
translate_key *key,
          unsigned size = vb->stride ? num_vertices * vb->stride
                                     : sizeof(double)*4;
 
-         if (!vb->buffer.resource)
+         if (!vb->buffer.resource) {
+            static uint64_t dummy_buf[4] = { 0 };
+            tr->set_buffer(tr, i, dummy_buf, 0, 0);
             continue;
+        }
 
          if (offset + size > vb->buffer.resource->width0) {
             /* Don't try to map past end of buffer.  This often happens when
diff --git a/src/gallium/drivers/zink/ci/piglit-zink-lvp-fails.txt 
b/src/gallium/drivers/zink/ci/piglit-zink-lvp-fails.txt
index 401960d260a..5cd9b383770 100644
--- a/src/gallium/drivers/zink/ci/piglit-zink-lvp-fails.txt
+++ b/src/gallium/drivers/zink/ci/piglit-zink-lvp-fails.txt
@@ -47,7 +47,6 @@ spec@!opengl 1.1@polygon-mode,Fail
 spec@!opengl 1.1@polygon-mode-facing,Fail
 spec@!opengl 1.1@polygon-mode-offset,Fail
 spec@!opengl 1.1@polygon-offset,Fail
-spec@!opengl 1.1@ppgtt_memory_alignment,Crash
 spec@!opengl 1.1@read-front,Fail
 spec@!opengl 1.1@read-front clear-front-first,Fail
 spec@!opengl 1.1@read-front clear-front-first samples=2,Fail

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to