Commit ee30840b authored by Dan Carpenter's avatar Dan Carpenter Committed by Melissa Wen

drm/v3d: fix copy_from_user() error codes

The copy_to/from_user() function returns the number of bytes remaining
to be copied, but we want to return -EFAULT on error.

Fixes: e4165ae8 ("drm/v3d: add multiple syncobjs support")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarMelissa Wen <mwen@igalia.com>
Signed-off-by: default avatarMelissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211011123303.GA14314@kili
parent f85d9e59
...@@ -487,8 +487,8 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv, ...@@ -487,8 +487,8 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
for (i = 0; i < se->in_sync_count; i++) { for (i = 0; i < se->in_sync_count; i++) {
struct drm_v3d_sem in; struct drm_v3d_sem in;
ret = copy_from_user(&in, handle++, sizeof(in)); if (copy_from_user(&in, handle++, sizeof(in))) {
if (ret) { ret = -EFAULT;
DRM_DEBUG("Failed to copy wait dep handle.\n"); DRM_DEBUG("Failed to copy wait dep handle.\n");
goto fail_deps; goto fail_deps;
} }
...@@ -609,8 +609,8 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv, ...@@ -609,8 +609,8 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv,
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
struct drm_v3d_sem out; struct drm_v3d_sem out;
ret = copy_from_user(&out, post_deps++, sizeof(out)); if (copy_from_user(&out, post_deps++, sizeof(out))) {
if (ret) { ret = -EFAULT;
DRM_DEBUG("Failed to copy post dep handles\n"); DRM_DEBUG("Failed to copy post dep handles\n");
goto fail; goto fail;
} }
...@@ -646,9 +646,8 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv, ...@@ -646,9 +646,8 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,
struct v3d_submit_ext *se = data; struct v3d_submit_ext *se = data;
int ret; int ret;
ret = copy_from_user(&multisync, ext, sizeof(multisync)); if (copy_from_user(&multisync, ext, sizeof(multisync)))
if (ret) return -EFAULT;
return ret;
if (multisync.pad) if (multisync.pad)
return -EINVAL; return -EINVAL;
......
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