diff mbox

fbmem: return -EFAULT on copy_to_user() failure

Message ID 20130618070529.GA12329@elgon.mountain (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter June 18, 2013, 7:05 a.m. UTC
copy_to_user() returns the number of bytes remaining to be copied.
put_user() returns -EFAULT on error.

This function ORs a bunch of stuff together and returns jumbled non-zero
values on error.  It should return -EFAULT.

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

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Tomi Valkeinen June 26, 2013, 1:04 p.m. UTC | #1
On 18/06/13 10:05, Dan Carpenter wrote:
> copy_to_user() returns the number of bytes remaining to be copied.
> put_user() returns -EFAULT on error.
> 
> This function ORs a bunch of stuff together and returns jumbled non-zero
> values on error.  It should return -EFAULT.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 098bfc6..9217be3 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1305,7 +1305,9 @@ static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
>  	err |= copy_to_user(fix32->reserved, fix->reserved,
>  			    sizeof(fix->reserved));
>  
> -	return err;
> +	if (err)
> +		return -EFAULT;
> +	return 0;
>  }
>  
>  static int fb_get_fscreeninfo(struct fb_info *info, unsigned int cmd,

I've added this to fbdev-3.11 branch.

 Tomi
diff mbox

Patch

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 098bfc6..9217be3 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1305,7 +1305,9 @@  static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
 	err |= copy_to_user(fix32->reserved, fix->reserved,
 			    sizeof(fix->reserved));
 
-	return err;
+	if (err)
+		return -EFAULT;
+	return 0;
 }
 
 static int fb_get_fscreeninfo(struct fb_info *info, unsigned int cmd,