rsxx: returning bytes remaining instead of -EFAULT
Subsystems (2)
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.
Signed-off-by Dan Carpenter <[email protected]>
drivers/block/rsxx/core.c +4 -6
@@ -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;
Quoted 22 lines · Dan Carpenter
copy_to/from_user() returns the number of bytes remaining to be copied. We should return
-EFAULThere instead.Signed-off-by Dan Carpenter <[email protected]>drivers/block/rsxx/core.c +2
-3@@ -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.