[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220112065135.692325-1-jiasheng@iscas.ac.cn>
Date: Wed, 12 Jan 2022 14:51:35 +0800
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: ebiggers@...nel.org
Cc: viro@...iv.linux.org.uk, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH v2] fs/eventfd.c: Check error number after calling ida_simple_get
As the possible failure of the allocation, the ida_simple_get() will
return error number.
And then ctx->id will be printed in eventfd_show_fdinfo().
Therefore, it should be better to check it and return error if fails,
like the other allocation.
Fixes: b556db17b0e7 ("eventfd: present id to userspace via fdinfo")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
Changelog
v1 -> v2
* Change 1. Correct the check condition.
---
fs/eventfd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/eventfd.c b/fs/eventfd.c
index 3627dd7d25db..3e226f6cbe4f 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -424,6 +424,10 @@ static int do_eventfd(unsigned int count, int flags)
ctx->count = count;
ctx->flags = flags;
ctx->id = ida_simple_get(&eventfd_ida, 0, 0, GFP_KERNEL);
+ if (ctx->id < 0) {
+ fd = ctx->id;
+ goto err;
+ }
flags &= EFD_SHARED_FCNTL_FLAGS;
flags |= O_RDWR;
--
2.25.1
Powered by blists - more mailing lists