From f5f8dd29c30e727c10ff087321d87c40c064de04 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 4 Aug 2014 18:30:33 -0700 Subject: [PATCH] vc4: Handle stride==0 in VBO validation --- src/gallium/drivers/vc4/vc4_simulator_validate.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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; -- 2.30.2