Skip to content

Commit

Permalink
vfio: Avoid repeated user pointer cast in vfio_device_fops_unl_ioctl()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yi Liu authored and Alex Williamson committed Jul 25, 2023
1 parent 1c9dc07 commit ca9e45b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/vfio/vfio_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() */
Expand All @@ -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:
Expand Down

0 comments on commit ca9e45b

Please sign in to comment.