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@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11515>
This commit is contained in:
luc
2021-06-22 07:41:44 +08:00
committed by Marge Bot
parent 0b2c79092c
commit 937e813d23

View File

@@ -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;