drm/msm: return -EFAULT instead of bytes remaining
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 13 Jul 2016 10:35:29 +0000 (13:35 +0300)
committerRob Clark <robdclark@gmail.com>
Sat, 16 Jul 2016 14:29:32 +0000 (10:29 -0400)
copy_to/from_user returns the number of bytes remaining to be copied but
we want to return -EFAULT.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/msm_perf.c
drivers/gpu/drm/msm/msm_rd.c

index 830857c47c86147614dfb64ac962a5247b6acc14..17fe4e53e0d163dbb262bf0607ff832acdcea2dd 100644 (file)
@@ -132,7 +132,7 @@ static ssize_t perf_read(struct file *file, char __user *buf,
                size_t sz, loff_t *ppos)
 {
        struct msm_perf_state *perf = file->private_data;
-       int n = 0, ret;
+       int n = 0, ret = 0;
 
        mutex_lock(&perf->read_lock);
 
@@ -143,9 +143,10 @@ static ssize_t perf_read(struct file *file, char __user *buf,
        }
 
        n = min((int)sz, perf->buftot - perf->bufpos);
-       ret = copy_to_user(buf, &perf->buf[perf->bufpos], n);
-       if (ret)
+       if (copy_to_user(buf, &perf->buf[perf->bufpos], n)) {
+               ret = -EFAULT;
                goto out;
+       }
 
        perf->bufpos += n;
        *ppos += n;
index 24254e07bcd58f6c1ea8c943e2c4f6866de286bf..3a5fdfcd67aeb7d29e315ff54a1eda27bf42372a 100644 (file)
@@ -149,9 +149,10 @@ static ssize_t rd_read(struct file *file, char __user *buf,
                goto out;
 
        n = min_t(int, sz, circ_count_to_end(&rd->fifo));
-       ret = copy_to_user(buf, fptr, n);
-       if (ret)
+       if (copy_to_user(buf, fptr, n)) {
+               ret = -EFAULT;
                goto out;
+       }
 
        fifo->tail = (fifo->tail + n) & (BUF_SZ - 1);
        *ppos += n;