panfrost: Correctly calculate prefetch suppresion varying index
authorIcecream95 <ixn@disroot.org>
Sun, 10 Jul 2022 08:57:24 +0000 (20:57 +1200)
committerMarge Bot <emma+marge@anholt.net>
Sat, 23 Jul 2022 00:56:10 +0000 (00:56 +0000)
The xfb_base is a base index, it makes no sense to multiply that with
the number of streamout targets. Use addition instead to fix a buffer
overflow.

Fixes: 557633b142e ("panfrost: Suppress Bifrost prefetching")
Reported-by: Luc Ma <onion0709@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17447>

src/gallium/drivers/panfrost/pan_cmdstream.c

index 0aa7a1b..17f4fb1 100644 (file)
@@ -2667,7 +2667,7 @@ panfrost_emit_varying_descriptor(struct panfrost_batch *batch,
 
 #if PAN_ARCH >= 6
         /* Suppress prefetch on Bifrost */
-        memset(varyings + (xfb_base * ctx->streamout.num_targets), 0, sizeof(*varyings));
+        memset(varyings + xfb_base + ctx->streamout.num_targets, 0, sizeof(*varyings));
 #else
         /* Emit the stream out buffers. We need enough room for all the
          * vertices we emit across all instances */