From 937e813d23f10edca30312a604e1efc37453bdbd Mon Sep 17 00:00:00 2001 From: luc Date: Tue, 22 Jun 2021 07:41:44 +0800 Subject: [PATCH] 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 Part-of: --- 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;