pan/midgard: Fix a divide by zero in emit_alu_bundle
authorIcecream95 <ixn@keemail.me>
Wed, 1 Apr 2020 02:32:19 +0000 (15:32 +1300)
committerMarge Bot <eric+marge@anholt.net>
Fri, 3 Apr 2020 16:49:04 +0000 (16:49 +0000)
util_dynarray_grow_bytes divides by eltsize, but it's possible for
bundle->padding to be zero.

I changed the other call to util_dynarray_grow_bytes for consistency.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4397>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4397>

src/panfrost/midgard/midgard_emit.c

index 2b18aac3553f7965fb7f53f5d1fa439eac74a77c..0c5d60efa4a90677ebb7cc0741125b7faf5b29df 100644 (file)
@@ -372,11 +372,11 @@ emit_alu_bundle(compiler_context *ctx,
                         source = &scalarized;
                 }
 
-                memcpy(util_dynarray_grow_bytes(emission, 1, size), source, size);
+                memcpy(util_dynarray_grow_bytes(emission, size, 1), source, size);
         }
 
         /* Emit padding (all zero) */
-        memset(util_dynarray_grow_bytes(emission, 1, bundle->padding), 0, bundle->padding);
+        memset(util_dynarray_grow_bytes(emission, bundle->padding, 1), 0, bundle->padding);
 
         /* Tack on constants */