timerfd: convert timerfd_create() to FD_ADD()

Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-15-b6efa1706cfd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
pull/1354/merge
Christian Brauner 2025-11-23 17:33:33 +01:00
parent 5b755da105
commit 14010faa1b
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
1 changed files with 9 additions and 20 deletions

View File

@ -393,9 +393,8 @@ static const struct file_operations timerfd_fops = {
SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
{ {
int ufd; struct timerfd_ctx *ctx __free(kfree) = NULL;
struct timerfd_ctx *ctx; int ret;
struct file *file;
/* Check the TFD_* constants for consistency. */ /* Check the TFD_* constants for consistency. */
BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC); BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC);
@ -432,23 +431,13 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
ctx->moffs = ktime_mono_to_real(0); ctx->moffs = ktime_mono_to_real(0);
ufd = get_unused_fd_flags(flags & TFD_SHARED_FCNTL_FLAGS); ret = FD_ADD(flags & TFD_SHARED_FCNTL_FLAGS,
if (ufd < 0) { anon_inode_getfile_fmode("[timerfd]", &timerfd_fops, ctx,
kfree(ctx);
return ufd;
}
file = anon_inode_getfile_fmode("[timerfd]", &timerfd_fops, ctx,
O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS), O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS),
FMODE_NOWAIT); FMODE_NOWAIT));
if (IS_ERR(file)) { if (ret >= 0)
put_unused_fd(ufd); retain_and_null_ptr(ctx);
kfree(ctx); return ret;
return PTR_ERR(file);
}
fd_install(ufd, file);
return ufd;
} }
static int do_timerfd_settime(int ufd, int flags, static int do_timerfd_settime(int ufd, int flags,