Commit b4ef52d2 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

drm: return -EFAULT if copy_to_user() fails

[ Upstream commit 74b67efa ]

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190618131843.GA29463@mwandaSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
parent d9298348
...@@ -1332,7 +1332,10 @@ static int copy_one_buf(void *data, int count, struct drm_buf_entry *from) ...@@ -1332,7 +1332,10 @@ static int copy_one_buf(void *data, int count, struct drm_buf_entry *from)
.size = from->buf_size, .size = from->buf_size,
.low_mark = from->low_mark, .low_mark = from->low_mark,
.high_mark = from->high_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, int drm_legacy_infobufs(struct drm_device *dev, void *data,
......
...@@ -372,7 +372,10 @@ static int copy_one_buf32(void *data, int count, struct drm_buf_entry *from) ...@@ -372,7 +372,10 @@ static int copy_one_buf32(void *data, int count, struct drm_buf_entry *from)
.size = from->buf_size, .size = from->buf_size,
.low_mark = from->low_mark, .low_mark = from->low_mark,
.high_mark = from->high_mark}; .high_mark = from->high_mark};
return copy_to_user(to + count, &v, offsetof(drm_buf_desc32_t, flags));
if (copy_to_user(to + count, &v, offsetof(drm_buf_desc32_t, flags)))
return -EFAULT;
return 0;
} }
static int drm_legacy_infobufs32(struct drm_device *dev, void *data, static int drm_legacy_infobufs32(struct drm_device *dev, void *data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment