Skip to contentSkip to conversation

rsxx: returning bytes remaining instead of -EFAULT

PATCH In review Dan Carpenter 2 participants 2 messages Jun 21, 2013

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

PATCH 1/1 rsxx: returning bytes remaining instead of -EFAULT

copy_to/from_user() returns the number of bytes remaining to be copied. We should return -EFAULT here instead.

drivers/block/rsxx/core.c +4 -6
index 6e85e21..102dc60 100644
@@ -199,9 +199,8 @@ static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf,
 	if (st)
 		return st;
 
-	st = copy_to_user(ubuf, buf, cnt);
-	if (st)
-		return st;
+	if (copy_to_user(ubuf, buf, cnt))
+		return -EFAULT;
 
 	info->offset += cnt;
 
@@ -222,9 +221,8 @@ static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf,
 	if (!buf)
 		return -ENOMEM;
 
-	st = copy_from_user(buf, ubuf, cnt);
-	if (st)
-		return st;
+	if (copy_from_user(buf, ubuf, cnt))
+		return -EFAULT;
 
 	info->f_pos = (u32)*ppos + info->offset;
 
#1 lore raw
Quoted 22 lines · Dan Carpenter

copy_to/from_user() returns the number of bytes remaining to be copied. We should return -EFAULT here instead.

drivers/block/rsxx/core.c +2 -3
index 6e85e21..102dc60 100644
@@ -199,9 +199,8 @@ static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf,
 	if (st)
 		return st;
 
-	st = copy_to_user(ubuf, buf, cnt);
-	if (st)
-		return st;
+	if (copy_to_user(ubuf, buf, cnt))
+		return -EFAULT;
 
 	info->offset += cnt;
 

drivers/block/rsxx/core.c static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf, · line 227

Quoted 10 lines
drivers/block/rsxx/core.c +2 -3
@@ -222,9 +221,8 @@ static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf,
 	if (!buf)
 		return -ENOMEM;
 
-	st = copy_from_user(buf, ubuf, cnt);
-	if (st)
-		return st;
+	if (copy_from_user(buf, ubuf, cnt))
+		return -EFAULT;
 
 	info->f_pos = (u32)*ppos + info->offset;

Thank You for noticing that mistake on my part.

Quoted 2 lines