Skip to content

Commit

Permalink
i915: return -EFAULT if copy_to_user fails
Browse files Browse the repository at this point in the history
copy_to_user returns the number of bytes remaining to be copied, but we
want to return a negative error code here.  These are returned to
userspace.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: stable@kernel.org
  • Loading branch information
Dan Carpenter authored and Chris Wilson committed Sep 6, 2010
1 parent df51e7a commit 9927a40
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/gpu/drm/i915/i915_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,10 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
ret = copy_from_user(cliprects, batch->cliprects,
batch->num_cliprects *
sizeof(struct drm_clip_rect));
if (ret != 0)
if (ret != 0) {
ret = -EFAULT;
goto fail_free;
}
}

mutex_lock(&dev->struct_mutex);
Expand Down Expand Up @@ -662,8 +664,10 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
return -ENOMEM;

ret = copy_from_user(batch_data, cmdbuf->buf, cmdbuf->sz);
if (ret != 0)
if (ret != 0) {
ret = -EFAULT;
goto fail_batch_free;
}

if (cmdbuf->num_cliprects) {
cliprects = kcalloc(cmdbuf->num_cliprects,
Expand All @@ -676,8 +680,10 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
ret = copy_from_user(cliprects, cmdbuf->cliprects,
cmdbuf->num_cliprects *
sizeof(struct drm_clip_rect));
if (ret != 0)
if (ret != 0) {
ret = -EFAULT;
goto fail_clip_free;
}
}

mutex_lock(&dev->struct_mutex);
Expand Down

0 comments on commit 9927a40

Please sign in to comment.