Skip to contentSkip to conversation

drm/msm: return -EFAULT instead of bytes remaining

PATCH In review Dan Carpenter 2 participants 2 messages Jul 13, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

drivers/gpu/drm/msm/msm_perf.c +4 -3
index 830857c..17fe4e5 100644
@@ -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;
drivers/gpu/drm/msm/msm_rd.c +3 -2
index 24254e0..3a5fdfc 100644
@@ -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;

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#1 lore raw
Quoted 4 lines · Dan Carpenter

copy_to/from_user returns the number of bytes remaining to be copied but we want to return -EFAULT.

thanks, I've added to msm-next

BR,
-R

Quoted 34 lines
drivers/gpu/drm/msm/msm_perf.c +4 -3
index 830857c..17fe4e5 100644
@@ -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;
drivers/gpu/drm/msm/msm_rd.c +0 -0
index 24254e0..3a5fdfc 100644
@@ -149,9 +149,10 @@ static ssize_t rd_read(struct file *file, char __user *buf,
                goto out;
 

drivers/gpu/drm/msm/msm_rd.c static ssize_t rd_read(struct file *file, char __user *buf, · line 158

Quoted 10 lines
drivers/gpu/drm/msm/msm_rd.c +3 -2
        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;

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno