Mesa (main): panfrost: Only clear existing color buffers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 6 15:32:35 UTC 2021


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

Author: luc <onion0709 at gmail.com>
Date:   Tue Jun 22 07:41:44 2021 +0800

panfrost: Only clear existing color buffers

    in case that only one cbuf allocated but all clear bits set,
    the driver will crash due to null pointer dereference.

Signed-off-by: luc <onion0709 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11515>

---

 src/gallium/drivers/panfrost/pan_job.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index 31cd444c873..c2a0064f857 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -1153,7 +1153,7 @@ panfrost_batch_clear(struct panfrost_batch *batch,
         struct panfrost_context *ctx = batch->ctx;
 
         if (buffers & PIPE_CLEAR_COLOR) {
-                for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; ++i) {
+                for (unsigned i = 0; i < ctx->pipe_framebuffer.nr_cbufs; ++i) {
                         if (!(buffers & (PIPE_CLEAR_COLOR0 << i)))
                                 continue;
 



More information about the mesa-commit mailing list