@@ -423,20 +423,11 @@ static int do_eventfd(unsigned int count, int flags)
ctx->count = count;
ctx->flags = flags;
ctx->id = ida_simple_get(&eventfd_ida, 0, 0, GFP_KERNEL);
-
- flags &= EFD_SHARED_FCNTL_FLAGS;
- flags |= O_RDWR;
- fd = get_unused_fd_flags(flags);
+ fd = __anon_inode_getfd("[eventfd]", &eventfd_fops, ctx,
+ (flags & EFD_SHARED_FCNTL_FLAGS) | O_RDWR, &file);
if (fd < 0)
goto err;
- file = anon_inode_getfile("[eventfd]", &eventfd_fops, ctx, flags);
- if (IS_ERR(file)) {
- put_unused_fd(fd);
- fd = PTR_ERR(file);
- goto err;
- }
-
file->f_mode |= FMODE_NOWAIT;
fd_install(fd, file);
return fd;
Use __anon_inode_getfd instead of opencoding the logic using get_unused_fd_flags + anon_inode_getfile. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/eventfd.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)