mirror of https://github.com/torvalds/linux.git
vfio: convert vfio_group_ioctl_get_device_fd() to FD_ADD()
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-43-b6efa1706cfd@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
3fd5edfe1d
commit
5f3ea1c201
|
|
@ -299,10 +299,8 @@ static int vfio_group_ioctl_get_device_fd(struct vfio_group *group,
|
||||||
char __user *arg)
|
char __user *arg)
|
||||||
{
|
{
|
||||||
struct vfio_device *device;
|
struct vfio_device *device;
|
||||||
struct file *filep;
|
|
||||||
char *buf;
|
char *buf;
|
||||||
int fdno;
|
int fd;
|
||||||
int ret;
|
|
||||||
|
|
||||||
buf = strndup_user(arg, PAGE_SIZE);
|
buf = strndup_user(arg, PAGE_SIZE);
|
||||||
if (IS_ERR(buf))
|
if (IS_ERR(buf))
|
||||||
|
|
@ -313,26 +311,10 @@ static int vfio_group_ioctl_get_device_fd(struct vfio_group *group,
|
||||||
if (IS_ERR(device))
|
if (IS_ERR(device))
|
||||||
return PTR_ERR(device);
|
return PTR_ERR(device);
|
||||||
|
|
||||||
fdno = get_unused_fd_flags(O_CLOEXEC);
|
fd = FD_ADD(O_CLOEXEC, vfio_device_open_file(device));
|
||||||
if (fdno < 0) {
|
if (fd < 0)
|
||||||
ret = fdno;
|
vfio_device_put_registration(device);
|
||||||
goto err_put_device;
|
return fd;
|
||||||
}
|
|
||||||
|
|
||||||
filep = vfio_device_open_file(device);
|
|
||||||
if (IS_ERR(filep)) {
|
|
||||||
ret = PTR_ERR(filep);
|
|
||||||
goto err_put_fdno;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd_install(fdno, filep);
|
|
||||||
return fdno;
|
|
||||||
|
|
||||||
err_put_fdno:
|
|
||||||
put_unused_fd(fdno);
|
|
||||||
err_put_device:
|
|
||||||
vfio_device_put_registration(device);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_group_ioctl_get_status(struct vfio_group *group,
|
static int vfio_group_ioctl_get_status(struct vfio_group *group,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue