summaryrefslogtreecommitdiff
path: root/drivers/vfio
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2025-11-23 17:34:01 +0100
committerChristian Brauner <brauner@kernel.org>2025-11-28 12:42:36 +0100
commit5f3ea1c201088290f66445b601a21fd89a398f88 (patch)
tree9fc0d00dc408988b150d9247906b1cfbc8ab90cc /drivers/vfio
parent3fd5edfe1d6fcc67410be753dcb704d8a1d0bfd7 (diff)
downloadlinux-5f3ea1c201088290f66445b601a21fd89a398f88.tar.gz
linux-5f3ea1c201088290f66445b601a21fd89a398f88.tar.bz2
linux-5f3ea1c201088290f66445b601a21fd89a398f88.zip
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>
Diffstat (limited to 'drivers/vfio')
-rw-r--r--drivers/vfio/group.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/drivers/vfio/group.c b/drivers/vfio/group.c
index c376a6279de0..d47ffada6912 100644
--- a/drivers/vfio/group.c
+++ b/drivers/vfio/group.c
@@ -299,10 +299,8 @@ static int vfio_group_ioctl_get_device_fd(struct vfio_group *group,
char __user *arg)
{
struct vfio_device *device;
- struct file *filep;
char *buf;
- int fdno;
- int ret;
+ int fd;
buf = strndup_user(arg, PAGE_SIZE);
if (IS_ERR(buf))
@@ -313,26 +311,10 @@ static int vfio_group_ioctl_get_device_fd(struct vfio_group *group,
if (IS_ERR(device))
return PTR_ERR(device);
- fdno = get_unused_fd_flags(O_CLOEXEC);
- if (fdno < 0) {
- ret = fdno;
- goto err_put_device;
- }
-
- 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;
+ fd = FD_ADD(O_CLOEXEC, vfio_device_open_file(device));
+ if (fd < 0)
+ vfio_device_put_registration(device);
+ return fd;
}
static int vfio_group_ioctl_get_status(struct vfio_group *group,