[Intel-gfx] [PATCH v9 09/10] vfio/pci: Copy hot-reset device info to userspace in the devices loop
Liu, Yi L
yi.l.liu at intel.com
Sat Jul 15 04:20:21 UTC 2023
> From: Jason Gunthorpe <jgg at nvidia.com>
> Sent: Friday, July 14, 2023 9:37 PM
>
> On Mon, Jul 10, 2023 at 07:31:25PM -0700, Yi Liu wrote:
>
> > @@ -1311,29 +1296,17 @@ static int vfio_pci_ioctl_get_pci_hot_reset_info(
> > ret = vfio_pci_for_each_slot_or_bus(vdev->pdev, vfio_pci_fill_devs,
> > &fill, slot);
> > mutex_unlock(&vdev->vdev.dev_set->lock);
> > + if (ret)
> > + return ret;
> >
> > - /*
> > - * If a device was removed between counting and filling, we may come up
> > - * short of fill.max. If a device was added, we'll have a return of
> > - * -EAGAIN above.
> > - */
> > - if (!ret) {
> > - hdr.count = fill.cur;
> > - hdr.flags = fill.flags;
> > - }
> > -
> > -reset_info_exit:
> > + hdr.count = fill.count;
> > + hdr.flags = fill.flags;
> > if (copy_to_user(arg, &hdr, minsz))
> > - ret = -EFAULT;
> > -
> > - if (!ret) {
> > - if (copy_to_user(&arg->devices, devices,
> > - hdr.count * sizeof(*devices)))
> > - ret = -EFAULT;
> > - }
> > + return -EFAULT;
> >
> > - kfree(devices);
> > - return ret;
> > + if (fill.count != fill.devices - arg->devices)
> > + return -ENOSPC;
>
> This should be > right? The previous code returned ENOSPC only if
> their were more devices than requested, not less.
Yes. it is.
Regards,
Yi Liu
More information about the Intel-gfx
mailing list