summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/drm_bufs.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2019-06-18 16:18:43 +0300
committerSean Paul <seanpaul@chromium.org>2019-06-18 20:08:48 +0300
commit74b67efa8d7b4f90137f0ab9a80dd319da050350 (patch)
tree9c31e46a940090bf50414deef0f19444f28630a2 /drivers/gpu/drm/drm_bufs.c
parent9870dc39dc53c0ab0534e1d8311a4abed7db570e (diff)
downloadlinux-74b67efa8d7b4f90137f0ab9a80dd319da050350.tar.xz
drm: return -EFAULT if copy_to_user() fails
The copy_from_user() function returns the number of bytes remaining to be copied but we want to return a negative error code. Otherwise the callers treat it as a successful copy. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Sean Paul <seanpaul@chromium.org> Link: https://patchwork.freedesktop.org/patch/msgid/20190618131843.GA29463@mwanda
Diffstat (limited to 'drivers/gpu/drm/drm_bufs.c')
-rw-r--r--drivers/gpu/drm/drm_bufs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index bfc419ed9d6c..ceca79b1468d 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1340,7 +1340,10 @@ static int copy_one_buf(void *data, int count, struct drm_buf_entry *from)
.size = from->buf_size,
.low_mark = from->low_mark,
.high_mark = from->high_mark};
- return copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags));
+
+ if (copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags)))
+ return -EFAULT;
+ return 0;
}
int drm_legacy_infobufs(struct drm_device *dev, void *data,