vc4: Handle stride==0 in VBO validation
authorEric Anholt <eric@anholt.net>
Tue, 5 Aug 2014 01:30:33 +0000 (18:30 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 11 Aug 2014 21:45:32 +0000 (14:45 -0700)
src/gallium/drivers/vc4/vc4_simulator_validate.c

index 421107a0b0582c66663eb5f70f7327df89ea465c..038de0fc637aa9a8c629ea08455219ed2e1dcf66 100644 (file)
@@ -942,18 +942,20 @@ validate_shader_rec(struct drm_device *dev,
                        stride |= (*(uint32_t *)(pkt_u + 100 + i * 4)) & ~0xff;
 
                if (vbo->base.size < offset ||
-                   vbo->base.size - offset < attr_size ||
-                   stride == 0) {
+                   vbo->base.size - offset < attr_size) {
                        DRM_ERROR("BO offset overflow (%d + %d > %d)\n",
                                  offset, attr_size, vbo->base.size);
                        return -EINVAL;
                }
 
-               max_index = (vbo->base.size - offset - attr_size) / stride;
-               if (state->max_index > max_index) {
-                       DRM_ERROR("primitives use index %d out of supplied %d\n",
-                                 state->max_index, max_index);
-                       return -EINVAL;
+               if (stride != 0) {
+                       max_index = ((vbo->base.size - offset - attr_size) /
+                                    stride);
+                       if (state->max_index > max_index) {
+                               DRM_ERROR("primitives use index %d out of supplied %d\n",
+                                         state->max_index, max_index);
+                               return -EINVAL;
+                       }
                }
 
                *(uint32_t *)(pkt_v + o) = vbo->paddr + offset;