Commit 5745d21f authored by Dan Carpenter's avatar Dan Carpenter Committed by Rob Clark

drm/msm: return -EFAULT instead of bytes remaining

copy_to/from_user returns the number of bytes remaining to be copied but
we want to return -EFAULT.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent 06f32172
...@@ -132,7 +132,7 @@ static ssize_t perf_read(struct file *file, char __user *buf, ...@@ -132,7 +132,7 @@ static ssize_t perf_read(struct file *file, char __user *buf,
size_t sz, loff_t *ppos) size_t sz, loff_t *ppos)
{ {
struct msm_perf_state *perf = file->private_data; struct msm_perf_state *perf = file->private_data;
int n = 0, ret; int n = 0, ret = 0;
mutex_lock(&perf->read_lock); mutex_lock(&perf->read_lock);
...@@ -143,9 +143,10 @@ static ssize_t perf_read(struct file *file, char __user *buf, ...@@ -143,9 +143,10 @@ static ssize_t perf_read(struct file *file, char __user *buf,
} }
n = min((int)sz, perf->buftot - perf->bufpos); n = min((int)sz, perf->buftot - perf->bufpos);
ret = copy_to_user(buf, &perf->buf[perf->bufpos], n); if (copy_to_user(buf, &perf->buf[perf->bufpos], n)) {
if (ret) ret = -EFAULT;
goto out; goto out;
}
perf->bufpos += n; perf->bufpos += n;
*ppos += n; *ppos += n;
......
...@@ -149,9 +149,10 @@ static ssize_t rd_read(struct file *file, char __user *buf, ...@@ -149,9 +149,10 @@ static ssize_t rd_read(struct file *file, char __user *buf,
goto out; goto out;
n = min_t(int, sz, circ_count_to_end(&rd->fifo)); n = min_t(int, sz, circ_count_to_end(&rd->fifo));
ret = copy_to_user(buf, fptr, n); if (copy_to_user(buf, fptr, n)) {
if (ret) ret = -EFAULT;
goto out; goto out;
}
fifo->tail = (fifo->tail + n) & (BUF_SZ - 1); fifo->tail = (fifo->tail + n) & (BUF_SZ - 1);
*ppos += n; *ppos += n;
......
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