Skip to content

Commit 09699e5

Browse files
Dan CarpenterAlex Williamson
authored andcommitted
vfio/fsl-mc: return -EFAULT if copy_to_user() fails
The copy_to_user() function returns the number of bytes remaining to be copied, but this code should return -EFAULT. Fixes: df747bc ("vfio/fsl-mc: Implement VFIO_DEVICE_GET_REGION_INFO ioctl call") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Diana Craciun <diana.craciun@oss.nxp.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 572f64c commit 09699e5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/vfio/fsl-mc/vfio_fsl_mc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd,
248248
info.size = vdev->regions[info.index].size;
249249
info.flags = vdev->regions[info.index].flags;
250250

251-
return copy_to_user((void __user *)arg, &info, minsz);
251+
if (copy_to_user((void __user *)arg, &info, minsz))
252+
return -EFAULT;
253+
return 0;
252254
}
253255
case VFIO_DEVICE_GET_IRQ_INFO:
254256
{
@@ -267,7 +269,9 @@ static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd,
267269
info.flags = VFIO_IRQ_INFO_EVENTFD;
268270
info.count = 1;
269271

270-
return copy_to_user((void __user *)arg, &info, minsz);
272+
if (copy_to_user((void __user *)arg, &info, minsz))
273+
return -EFAULT;
274+
return 0;
271275
}
272276
case VFIO_DEVICE_SET_IRQS:
273277
{

0 commit comments

Comments
 (0)