linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] rsxx: returning bytes remaining instead of -EFAULT
@ 2013-06-21  6:21 Dan Carpenter
  2013-06-21 14:09 ` Philip J. Kelleher
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2013-06-21  6:21 UTC (permalink / raw)
  To: Joshua Morris; +Cc: Philip Kelleher, linux-kernel, kernel-janitors

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

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index 6e85e21..102dc60 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -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;
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] rsxx: returning bytes remaining instead of -EFAULT
  2013-06-21  6:21 [patch] rsxx: returning bytes remaining instead of -EFAULT Dan Carpenter
@ 2013-06-21 14:09 ` Philip J. Kelleher
  0 siblings, 0 replies; 2+ messages in thread
From: Philip J. Kelleher @ 2013-06-21 14:09 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Joshua Morris, linux-kernel, kernel-janitors

On Fri, Jun 21, 2013 at 09:21:11AM +0300, Dan Carpenter wrote:
> copy_to/from_user() returns the number of bytes remaining to be copied.
> We should return -EFAULT here instead.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
> index 6e85e21..102dc60 100644
> --- a/drivers/block/rsxx/core.c
> +++ b/drivers/block/rsxx/core.c
> @@ -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;

Thank You for noticing that mistake on my part.

> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-21 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-21  6:21 [patch] rsxx: returning bytes remaining instead of -EFAULT Dan Carpenter
2013-06-21 14:09 ` Philip J. Kelleher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).