[PATCH] fs/epoll: Simplify error case
From: Yejune Deng
Date: Wed Jun 02 2021 - 04:47:09 EST
There is only one failure case, so there is no need
to use goto statements and define error.
Signed-off-by: Yejune Deng <yejunedeng@xxxxxxxxx>
---
fs/eventpoll.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 1e596e1..b53f263 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -928,15 +928,15 @@ 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;
+ if (unlikely(!ep)) {
+ free_uid(user);
+ return -ENOMEM;
+ }
mutex_init(&ep->mtx);
rwlock_init(&ep->lock);
@@ -950,10 +950,6 @@ static int ep_alloc(struct eventpoll **pep)
*pep = ep;
return 0;
-
-free_uid:
- free_uid(user);
- return error;
}
/*
--
2.7.4