Skip to content

Commit af66279

Browse files
committed
ntsync: convert ntsync_obj_get_fd() to FD_PREPARE()
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-41-b6efa1706cfd@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 6f504cb commit af66279

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

drivers/misc/ntsync.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -721,21 +721,12 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev,
721721

722722
static int ntsync_obj_get_fd(struct ntsync_obj *obj)
723723
{
724-
struct file *file;
725-
int fd;
726-
727-
fd = get_unused_fd_flags(O_CLOEXEC);
728-
if (fd < 0)
729-
return fd;
730-
file = anon_inode_getfile("ntsync", &ntsync_obj_fops, obj, O_RDWR);
731-
if (IS_ERR(file)) {
732-
put_unused_fd(fd);
733-
return PTR_ERR(file);
734-
}
735-
obj->file = file;
736-
fd_install(fd, file);
737-
738-
return fd;
724+
FD_PREPARE(fdf, O_CLOEXEC,
725+
anon_inode_getfile("ntsync", &ntsync_obj_fops, obj, O_RDWR));
726+
if (fdf.err)
727+
return fdf.err;
728+
obj->file = fd_prepare_file(fdf);
729+
return fd_publish(fdf);
739730
}
740731

741732
static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp)

0 commit comments

Comments
 (0)