]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/msm: fix an error code in the ioctl
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 14 Feb 2019 07:19:27 +0000 (10:19 +0300)
committerRob Clark <robdclark@gmail.com>
Tue, 19 Feb 2019 19:53:50 +0000 (14:53 -0500)
The copy_to/from_user() functions return the number of bytes remaining
to be copied but we should return -EFAULT to the user.

Fixes: aa3287591b0b ("drm/msm: add uapi to get/set debug name")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/msm_drv.c

index 5e7b5fa01401e67e710fec97e72843213cb97ed0..87eae44a10065e0a0ba6acca26ac11207417a9d6 100644 (file)
@@ -851,8 +851,9 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
                        ret = -EINVAL;
                        break;
                }
-               ret = copy_from_user(msm_obj->name,
-                       u64_to_user_ptr(args->value), args->len);
+               if (copy_from_user(msm_obj->name, u64_to_user_ptr(args->value),
+                                  args->len))
+                       ret = -EFAULT;
                msm_obj->name[args->len] = '\0';
                for (i = 0; i < args->len; i++) {
                        if (!isprint(msm_obj->name[i])) {
@@ -868,8 +869,9 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
                }
                args->len = strlen(msm_obj->name);
                if (args->value) {
-                       ret = copy_to_user(u64_to_user_ptr(args->value),
-                                       msm_obj->name, args->len);
+                       if (copy_to_user(u64_to_user_ptr(args->value),
+                                        msm_obj->name, args->len))
+                               ret = -EFAULT;
                }
                break;
        }