Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+5 -23
+5 -23
drivers/vfio/group.c
··· 299 299 char __user *arg) 300 300 { 301 301 struct vfio_device *device; 302 - struct file *filep; 303 302 char *buf; 304 - int fdno; 305 - int ret; 303 + int fd; 306 304 307 305 buf = strndup_user(arg, PAGE_SIZE); 308 306 if (IS_ERR(buf)) ··· 311 313 if (IS_ERR(device)) 312 314 return PTR_ERR(device); 313 315 314 - fdno = get_unused_fd_flags(O_CLOEXEC); 315 - if (fdno < 0) { 316 - ret = fdno; 317 - goto err_put_device; 318 - } 319 - 320 - filep = vfio_device_open_file(device); 321 - if (IS_ERR(filep)) { 322 - ret = PTR_ERR(filep); 323 - goto err_put_fdno; 324 - } 325 - 326 - fd_install(fdno, filep); 327 - return fdno; 328 - 329 - err_put_fdno: 330 - put_unused_fd(fdno); 331 - err_put_device: 332 - vfio_device_put_registration(device); 333 - return ret; 316 + fd = FD_ADD(O_CLOEXEC, vfio_device_open_file(device)); 317 + if (fd < 0) 318 + vfio_device_put_registration(device); 319 + return fd; 334 320 } 335 321 336 322 static int vfio_group_ioctl_get_status(struct vfio_group *group,