@@ -1641,6 +1641,9 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
if (args->count_handles == 0)
return -EINVAL;
+ if (!access_ok(points, args->count_handles * sizeof(*points)))
+ return -EFAULT;
+
ret = drm_syncobj_array_find(file_private,
u64_to_user_ptr(args->handles),
args->count_handles,
@@ -1682,10 +1685,10 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
point = 0;
}
dma_fence_put(fence);
- ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
- ret = ret ? -EFAULT : 0;
- if (ret)
+ if (put_user(point, points++)) {
+ ret = -EFAULT;
break;
+ }
}
drm_syncobj_array_free(syncobjs, args->count_handles);