提交 966d5bf5 编写于 作者: M Matthew Auld 提交者: Chris Wilson

drm/i915: convert to using range_overflows

Convert some of the obvious hand-rolled ranged overflow sanity checks to
our shiny new range_overflows macro.

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Suggested-by: NChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: NMatthew Auld <matthew.auld@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161213203222.32564-4-matthew.auld@intel.comReviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
上级 86e61735
...@@ -1140,8 +1140,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, ...@@ -1140,8 +1140,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
return -ENOENT; return -ENOENT;
/* Bounds check source. */ /* Bounds check source. */
if (args->offset > obj->base.size || if (range_overflows_t(u64, args->offset, args->size, obj->base.size)) {
args->size > obj->base.size - args->offset) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -1454,8 +1453,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, ...@@ -1454,8 +1453,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
return -ENOENT; return -ENOENT;
/* Bounds check destination. */ /* Bounds check destination. */
if (args->offset > obj->base.size || if (range_overflows_t(u64, args->offset, args->size, obj->base.size)) {
args->size > obj->base.size - args->offset) {
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
} }
......
...@@ -176,10 +176,9 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level, ...@@ -176,10 +176,9 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
if (bind_flags == 0) if (bind_flags == 0)
return 0; return 0;
if (GEM_WARN_ON(vma->node.start + vma->node.size < vma->node.start)) if (GEM_WARN_ON(range_overflows(vma->node.start,
return -ENODEV; vma->node.size,
vma->vm->total)))
if (GEM_WARN_ON(vma->node.start + vma->node.size > vma->vm->total))
return -ENODEV; return -ENODEV;
if (vma_flags == 0 && vma->vm->allocate_va_range) { if (vma_flags == 0 && vma->vm->allocate_va_range) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册