summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-09-26 20:21:44 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-10-03 14:16:18 +0100
commit7dcd2499deab8f10011713c40bc2f309c9b65077 (patch)
tree1fc0476339e3fabd6b2a5f62dba1fd10abfd82f8 /drivers/gpu
parentce9d419dbecc292cc3e06e8b1d6d123d3fa813a4 (diff)
downloadblackbird-op-linux-7dcd2499deab8f10011713c40bc2f309c9b65077.tar.gz
blackbird-op-linux-7dcd2499deab8f10011713c40bc2f309c9b65077.zip
drm/i915: Rephrase pwrite bounds checking to avoid any potential overflow
... and do the same for pread. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: stable@kernel.org
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 7749e78a7300..aa959c4a1836 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -471,12 +471,8 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
return -ENOENT;
obj_priv = to_intel_bo(obj);
- /* Bounds check source.
- *
- * XXX: This could use review for overflow issues...
- */
- if (args->offset > obj->size || args->size > obj->size ||
- args->offset + args->size > obj->size) {
+ /* Bounds check source. */
+ if (args->offset > obj->size || args->size > obj->size - args->offset) {
ret = -EINVAL;
goto err;
}
@@ -939,12 +935,8 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
return -ENOENT;
obj_priv = to_intel_bo(obj);
- /* Bounds check destination.
- *
- * XXX: This could use review for overflow issues...
- */
- if (args->offset > obj->size || args->size > obj->size ||
- args->offset + args->size > obj->size) {
+ /* Bounds check destination. */
+ if (args->offset > obj->size || args->size > obj->size - args->offset) {
ret = -EINVAL;
goto err;
}
OpenPOWER on IntegriCloud