summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhen Lei <thunder.leizhen@huawei.com>2023-07-26 11:21:35 +0800
committerChristian Brauner <brauner@kernel.org>2023-07-26 14:56:07 +0200
commit05f26f86f4a1f31d5ed2015ac1c89ea9da1d2bb7 (patch)
tree45fe87db01c99be821bf9fe2c8d3764a63d119f2
parent0d5a4f8f775ff990142cdc810a84eae078589d27 (diff)
epoll: simplify ep_alloc()
The get_current_user() does not fail, and moving it after kzalloc() can simplify the code a bit. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Message-Id: <20230726032135.933-1-thunder.leizhen@huaweicloud.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r--fs/eventpoll.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 4b1b3362f697..1d9a71a0c4c1 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -975,15 +975,11 @@ again:
static int ep_alloc(struct eventpoll **pep)
{
- int error;
- struct user_struct *user;
struct eventpoll *ep;
- user = get_current_user();
- error = -ENOMEM;
ep = kzalloc(sizeof(*ep), GFP_KERNEL);
if (unlikely(!ep))
- goto free_uid;
+ return -ENOMEM;
mutex_init(&ep->mtx);
rwlock_init(&ep->lock);
@@ -992,16 +988,12 @@ static int ep_alloc(struct eventpoll **pep)
INIT_LIST_HEAD(&ep->rdllist);
ep->rbr = RB_ROOT_CACHED;
ep->ovflist = EP_UNACTIVE_PTR;
- ep->user = user;
+ ep->user = get_current_user();
refcount_set(&ep->refcount, 1);
*pep = ep;
return 0;
-
-free_uid:
- free_uid(user);
- return error;
}
/*