vfio: Avoid repeated user pointer cast in vfio_device_fops_unl_ioctl()
authorYi Liu <yi.l.liu@intel.com>
Tue, 18 Jul 2023 13:55:46 +0000 (06:55 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 25 Jul 2023 16:20:15 +0000 (10:20 -0600)
This adds a local variable to store the user pointer cast result from arg.
It avoids the repeated casts in the code when more ioctls are added.

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Tested-by: Yanting Jiang <yanting.jiang@intel.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20230718135551.6592-22-yi.l.liu@intel.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio_main.c

index 5f7c3151d8c083bbb6f64580c67dc95e6cbdcfef..a2744cb64c6df1e43bc98ff585c12d569b9b520d 100644 (file)
@@ -1146,6 +1146,7 @@ static long vfio_device_fops_unl_ioctl(struct file *filep,
 {
        struct vfio_device_file *df = filep->private_data;
        struct vfio_device *device = df->device;
+       void __user *uptr = (void __user *)arg;
        int ret;
 
        /* Paired with smp_store_release() following vfio_df_open() */
@@ -1158,7 +1159,7 @@ static long vfio_device_fops_unl_ioctl(struct file *filep,
 
        switch (cmd) {
        case VFIO_DEVICE_FEATURE:
-               ret = vfio_ioctl_device_feature(device, (void __user *)arg);
+               ret = vfio_ioctl_device_feature(device, uptr);
                break;
 
        default: