Re: [patch] vfio/pci: return -EFAULT if copy_to_user fails

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

 



On Thu, Feb 25, 2016 at 10:52:12AM +0300, Dan Carpenter wrote:
> The copy_to_user() function returns the number of bytes that were not
> copied but we want to return -EFAULT on error here.
> 
> Fixes: 188ad9d6cbbc ('vfio/pci: Include sparse mmap capability for MSI-X table regions')

Where's this commit? In which tree?

> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> 
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index 1ce1d36..98059df 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -664,12 +664,11 @@ static long vfio_pci_ioctl(void *device_data,
>  				info.cap_offset = 0;
>  			} else {
>  				vfio_info_cap_shift(&caps, sizeof(info));
> -				ret = copy_to_user((void __user *)arg +
> -						   sizeof(info), caps.buf,
> -						   caps.size);
> -				if (ret) {
> +				if (copy_to_user((void __user *)arg +
> +						  sizeof(info), caps.buf,
> +						  caps.size)) {
>  					kfree(caps.buf);
> -					return ret;
> +					return -EFAULT;
>  				}
>  				info.cap_offset = sizeof(info);
>  			}
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux