linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] epoll: simplify ep_alloc()
@ 2023-07-26  3:21 thunder.leizhen
  2023-07-26  9:06 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: thunder.leizhen @ 2023-07-26  3:21 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, linux-fsdevel, linux-kernel; +Cc: Zhen Lei

From: Zhen Lei <thunder.leizhen@huawei.com>

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>
---
 fs/eventpoll.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 4b1b3362f697b11..1d9a71a0c4c1678 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -975,15 +975,11 @@ void eventpoll_release_file(struct file *file)
 
 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;
 }
 
 /*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] epoll: simplify ep_alloc()
  2023-07-26  3:21 [PATCH] epoll: simplify ep_alloc() thunder.leizhen
@ 2023-07-26  9:06 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2023-07-26  9:06 UTC (permalink / raw)
  To: thunder.leizhen
  Cc: Christian Brauner, Zhen Lei, Alexander Viro, linux-fsdevel,
	linux-kernel

On Wed, 26 Jul 2023 11:21:35 +0800, thunder.leizhen@huaweicloud.com wrote:
> The get_current_user() does not fail, and moving it after kzalloc() can
> simplify the code a bit.
> 
> 

Applied to the vfs.misc branch of the vfs/vfs.git tree.
Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[1/1] epoll: simplify ep_alloc()
      https://git.kernel.org/vfs/vfs/c/3f3ecbd73071

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-26  9:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26  3:21 [PATCH] epoll: simplify ep_alloc() thunder.leizhen
2023-07-26  9:06 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).