]> 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>
Tue, 15 Nov 2011 06:51:15 +0000 (09:51 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 26 Nov 2011 17:10:35 +0000 (09:10 -0800)
commit 7dcd2499deab8f10011713c40bc2f309c9b65077 upstream

... and do the same for pread.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/gpu/drm/i915/i915_gem.c

index e5de66ccffda7065ed0bce7f1baed8cff55f378f..27a3074f216c01987dc8f61f47301ae61df84a9c 100644 (file)
@@ -482,12 +482,8 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
                return -EBADF;
        obj_priv = obj->driver_private;
 
-       /* 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;
        }
@@ -960,12 +956,8 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
                return -EBADF;
        obj_priv = obj->driver_private;
 
-       /* 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;
        }