Skip to content

Commit ee30840

Browse files
Dan Carpentermelissawen
authored andcommitted
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: e4165ae ("drm/v3d: add multiple syncobjs support") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Melissa Wen <[email protected]> Signed-off-by: Melissa Wen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20211011123303.GA14314@kili
1 parent f85d9e5 commit ee30840

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/gpu/drm/v3d/v3d_gem.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
487487
for (i = 0; i < se->in_sync_count; i++) {
488488
struct drm_v3d_sem in;
489489

490-
ret = copy_from_user(&in, handle++, sizeof(in));
491-
if (ret) {
490+
if (copy_from_user(&in, handle++, sizeof(in))) {
491+
ret = -EFAULT;
492492
DRM_DEBUG("Failed to copy wait dep handle.\n");
493493
goto fail_deps;
494494
}
@@ -609,8 +609,8 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv,
609609
for (i = 0; i < count; i++) {
610610
struct drm_v3d_sem out;
611611

612-
ret = copy_from_user(&out, post_deps++, sizeof(out));
613-
if (ret) {
612+
if (copy_from_user(&out, post_deps++, sizeof(out))) {
613+
ret = -EFAULT;
614614
DRM_DEBUG("Failed to copy post dep handles\n");
615615
goto fail;
616616
}
@@ -646,9 +646,8 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,
646646
struct v3d_submit_ext *se = data;
647647
int ret;
648648

649-
ret = copy_from_user(&multisync, ext, sizeof(multisync));
650-
if (ret)
651-
return ret;
649+
if (copy_from_user(&multisync, ext, sizeof(multisync)))
650+
return -EFAULT;
652651

653652
if (multisync.pad)
654653
return -EINVAL;

0 commit comments

Comments
 (0)