Re: [PATCH 6/9] staging: vme_user: return -EFAULT on __copy_*_user errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 23, 2015 at 03:42:30PM +0300, Dmitry Kalinkin wrote:
> @@ -178,38 +167,24 @@ static ssize_t buffer_to_user(unsigned int minor, char __user *buf,
>  			      size_t count, loff_t *ppos)
>  {
>  	void *image_ptr;
> -	ssize_t retval;
>  
>  	image_ptr = image[minor].kern_buf + *ppos;
> +	if (__copy_to_user(buf, image_ptr, (unsigned long)count))
> +		return -EINVAL;

s/EINVAL/EFAULT/

>  
> -	retval = __copy_to_user(buf, image_ptr, (unsigned long)count);
> -	if (retval != 0) {
> -		retval = (count - retval);
> -		pr_warn("Partial copy to userspace\n");
> -	} else
> -		retval = count;
> -
> -	/* Return number of bytes successfully read */
> -	return retval;
> +	return count;
>  }
>  
>  static ssize_t buffer_from_user(unsigned int minor, const char __user *buf,
>  				size_t count, loff_t *ppos)
>  {
>  	void *image_ptr;
> -	size_t retval;
>  
>  	image_ptr = image[minor].kern_buf + *ppos;
> +	if (__copy_from_user(image_ptr, buf, (unsigned long)count))
> +		return -EINVAL;

s/EINVAL/EFAULT/

>  
> -	retval = __copy_from_user(image_ptr, buf, (unsigned long)count);
> -	if (retval != 0) {
> -		retval = (count - retval);
> -		pr_warn("Partial copy to userspace\n");
> -	} else
> -		retval = count;
> -
> -	/* Return number of bytes successfully read */
> -	return retval;
> +	return count;
>  }

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux