]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ntsync: convert ntsync_obj_get_fd() to FD_PREPARE()
authorChristian Brauner <brauner@kernel.org>
Sun, 23 Nov 2025 16:33:59 +0000 (17:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 28 Nov 2025 11:42:36 +0000 (12:42 +0100)
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-41-b6efa1706cfd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/misc/ntsync.c

index 999026a1ae0485763da7dbe8f263f83ca2fd01e5..9087f045e362737f81bc21f050306ddff35f54be 100644 (file)
@@ -721,21 +721,12 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev,
 
 static int ntsync_obj_get_fd(struct ntsync_obj *obj)
 {
-       struct file *file;
-       int fd;
-
-       fd = get_unused_fd_flags(O_CLOEXEC);
-       if (fd < 0)
-               return fd;
-       file = anon_inode_getfile("ntsync", &ntsync_obj_fops, obj, O_RDWR);
-       if (IS_ERR(file)) {
-               put_unused_fd(fd);
-               return PTR_ERR(file);
-       }
-       obj->file = file;
-       fd_install(fd, file);
-
-       return fd;
+       FD_PREPARE(fdf, O_CLOEXEC,
+                  anon_inode_getfile("ntsync", &ntsync_obj_fops, obj, O_RDWR));
+       if (fdf.err)
+               return fdf.err;
+       obj->file = fd_prepare_file(fdf);
+       return fd_publish(fdf);
 }
 
 static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp)