Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: e4165ae8304e ("drm/v3d: add multiple syncobjs support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211011123303.GA14314@kili

authored by

Dan Carpenter and committed by
Melissa Wen
ee30840b f85d9e59

+6 -7
+6 -7
drivers/gpu/drm/v3d/v3d_gem.c
··· 487 487 for (i = 0; i < se->in_sync_count; i++) { 488 488 struct drm_v3d_sem in; 489 489 490 - ret = copy_from_user(&in, handle++, sizeof(in)); 491 - if (ret) { 490 + if (copy_from_user(&in, handle++, sizeof(in))) { 491 + ret = -EFAULT; 492 492 DRM_DEBUG("Failed to copy wait dep handle.\n"); 493 493 goto fail_deps; 494 494 } ··· 609 609 for (i = 0; i < count; i++) { 610 610 struct drm_v3d_sem out; 611 611 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; 614 614 DRM_DEBUG("Failed to copy post dep handles\n"); 615 615 goto fail; 616 616 } ··· 646 646 struct v3d_submit_ext *se = data; 647 647 int ret; 648 648 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; 652 651 653 652 if (multisync.pad) 654 653 return -EINVAL;