@@ -3718,7 +3718,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
struct drm_i915_gem_object *obj_priv;
struct drm_clip_rect *cliprects = NULL;
struct drm_i915_gem_relocation_entry *relocs;
- int ret = 0, ret2, i, pinned = 0;
+ int ret = 0, ret2, i, pinned = 0, referenced;
uint64_t exec_offset;
uint32_t seqno, flush_domains, reloc_index;
int pin_tries, flips;
@@ -3787,6 +3787,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
DRM_ERROR("Invalid object handle %d at index %d\n",
exec_list[i].handle, i);
ret = -EBADF;
+ referenced = i + 1;
goto err;
}
@@ -3795,11 +3796,13 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
DRM_ERROR("Object %p appears more than once in object list\n",
object_list[i]);
ret = -EBADF;
+ referenced = i + 1;
goto err;
}
obj_priv->in_execbuffer = true;
flips += atomic_read(&obj_priv->pending_flip);
}
+ referenced = args->buffer_count;
if (flips > 0) {
ret = i915_gem_wait_for_pending_flip(dev, object_list,
@@ -3980,7 +3983,7 @@ err:
for (i = 0; i < pinned; i++)
i915_gem_object_unpin(object_list[i]);
- for (i = 0; i < args->buffer_count; i++) {
+ for (i = 0; i < referenced; i++) {
if (object_list[i]) {
obj_priv = object_list[i]->driver_private;
obj_priv->in_execbuffer = false;