[PATCH v9 09/10] vfio/pci: Copy hot-reset device info to userspace in the devices loop
Jason Gunthorpe
jgg at nvidia.com
Fri Jul 14 13:36:55 UTC 2023
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.
Jason
More information about the intel-gvt-dev
mailing list