From: Eric Anholt Date: Tue, 5 Aug 2014 01:30:33 +0000 (-0700) Subject: vc4: Handle stride==0 in VBO validation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f5f8dd29c30e727c10ff087321d87c40c064de04;p=mesa.git vc4: Handle stride==0 in VBO validation --- diff --git a/src/gallium/drivers/vc4/vc4_simulator_validate.c b/src/gallium/drivers/vc4/vc4_simulator_validate.c index 421107a0b05..038de0fc637 100644 --- a/src/gallium/drivers/vc4/vc4_simulator_validate.c +++ b/src/gallium/drivers/vc4/vc4_simulator_validate.c @@ -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;