mirror of https://github.com/torvalds/linux.git
eventpoll: convert do_epoll_create() to FD_PREPARE()
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-12-b6efa1706cfd@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
0f4288410c
commit
13dce771bb
|
|
@ -2165,9 +2165,8 @@ static void clear_tfile_check_list(void)
|
||||||
*/
|
*/
|
||||||
static int do_epoll_create(int flags)
|
static int do_epoll_create(int flags)
|
||||||
{
|
{
|
||||||
int error, fd;
|
int error;
|
||||||
struct eventpoll *ep = NULL;
|
struct eventpoll *ep;
|
||||||
struct file *file;
|
|
||||||
|
|
||||||
/* Check the EPOLL_* constant for consistency. */
|
/* Check the EPOLL_* constant for consistency. */
|
||||||
BUILD_BUG_ON(EPOLL_CLOEXEC != O_CLOEXEC);
|
BUILD_BUG_ON(EPOLL_CLOEXEC != O_CLOEXEC);
|
||||||
|
|
@ -2184,26 +2183,15 @@ static int do_epoll_create(int flags)
|
||||||
* Creates all the items needed to setup an eventpoll file. That is,
|
* Creates all the items needed to setup an eventpoll file. That is,
|
||||||
* a file structure and a free file descriptor.
|
* a file structure and a free file descriptor.
|
||||||
*/
|
*/
|
||||||
fd = get_unused_fd_flags(O_RDWR | (flags & O_CLOEXEC));
|
FD_PREPARE(fdf, O_RDWR | (flags & O_CLOEXEC),
|
||||||
if (fd < 0) {
|
anon_inode_getfile("[eventpoll]", &eventpoll_fops, ep,
|
||||||
error = fd;
|
O_RDWR | (flags & O_CLOEXEC)));
|
||||||
goto out_free_ep;
|
if (fdf.err) {
|
||||||
|
ep_clear_and_put(ep);
|
||||||
|
return fdf.err;
|
||||||
}
|
}
|
||||||
file = anon_inode_getfile("[eventpoll]", &eventpoll_fops, ep,
|
ep->file = fd_prepare_file(fdf);
|
||||||
O_RDWR | (flags & O_CLOEXEC));
|
return fd_publish(fdf);
|
||||||
if (IS_ERR(file)) {
|
|
||||||
error = PTR_ERR(file);
|
|
||||||
goto out_free_fd;
|
|
||||||
}
|
|
||||||
ep->file = file;
|
|
||||||
fd_install(fd, file);
|
|
||||||
return fd;
|
|
||||||
|
|
||||||
out_free_fd:
|
|
||||||
put_unused_fd(fd);
|
|
||||||
out_free_ep:
|
|
||||||
ep_clear_and_put(ep);
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSCALL_DEFINE1(epoll_create1, int, flags)
|
SYSCALL_DEFINE1(epoll_create1, int, flags)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue