]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/i915: Rephrase pwrite bounds checking to avoid any potential overflow
authorChris Wilson <chris@chris-wilson.co.uk>
Sun, 26 Sep 2010 19:21:44 +0000 (20:21 +0100)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Fri, 17 Aug 2012 19:35:56 +0000 (15:35 -0400)
commit 7dcd2499deab8f10011713c40bc2f309c9b65077 upstream.

... and do the same for pread.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
drivers/gpu/drm/i915/i915_gem.c

index fd51c36ac630145c2619635ad8e3c814162a84f3..82d798b079e70f167b5f79d33c27bee892186e8a 100644 (file)
@@ -481,12 +481,8 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
                return -EBADF;
        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;
        }
@@ -959,12 +955,8 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
                return -EBADF;
        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;
        }