aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samples/vfio-mdev/mtty.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 1fc57a5093a7..975af5bbf28d 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -1180,7 +1180,10 @@ static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
1180 1180
1181 memcpy(&mdev_state->dev_info, &info, sizeof(info)); 1181 memcpy(&mdev_state->dev_info, &info, sizeof(info));
1182 1182
1183 return copy_to_user((void __user *)arg, &info, minsz); 1183 if (copy_to_user((void __user *)arg, &info, minsz))
1184 return -EFAULT;
1185
1186 return 0;
1184 } 1187 }
1185 case VFIO_DEVICE_GET_REGION_INFO: 1188 case VFIO_DEVICE_GET_REGION_INFO:
1186 { 1189 {
@@ -1201,7 +1204,10 @@ static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
1201 if (ret) 1204 if (ret)
1202 return ret; 1205 return ret;
1203 1206
1204 return copy_to_user((void __user *)arg, &info, minsz); 1207 if (copy_to_user((void __user *)arg, &info, minsz))
1208 return -EFAULT;
1209
1210 return 0;
1205 } 1211 }
1206 1212
1207 case VFIO_DEVICE_GET_IRQ_INFO: 1213 case VFIO_DEVICE_GET_IRQ_INFO:
@@ -1224,7 +1230,10 @@ static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
1224 if (info.count == -1) 1230 if (info.count == -1)
1225 return -EINVAL; 1231 return -EINVAL;
1226 1232
1227 return copy_to_user((void __user *)arg, &info, minsz); 1233 if (copy_to_user((void __user *)arg, &info, minsz))
1234 return -EFAULT;
1235
1236 return 0;
1228 } 1237 }
1229 case VFIO_DEVICE_SET_IRQS: 1238 case VFIO_DEVICE_SET_IRQS:
1230 { 1239 {