* [PATCH] fs/eventfd.c: Check error number after calling ida_simple_get
@ 2022-01-11 7:00 Jiasheng Jiang
2022-01-12 6:35 ` Eric Biggers
0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-01-11 7:00 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel, Jiasheng Jiang
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@iscas.ac.cn>
---
fs/eventfd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/eventfd.c b/fs/eventfd.c
index 3627dd7d25db..5ec1d998f3ac 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) {
+ fd = ctx->id;
+ goto err;
+ }
flags &= EFD_SHARED_FCNTL_FLAGS;
flags |= O_RDWR;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fs/eventfd.c: Check error number after calling ida_simple_get
2022-01-11 7:00 [PATCH] fs/eventfd.c: Check error number after calling ida_simple_get Jiasheng Jiang
@ 2022-01-12 6:35 ` Eric Biggers
0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2022-01-12 6:35 UTC (permalink / raw)
To: Jiasheng Jiang; +Cc: viro, linux-fsdevel, linux-kernel
On Tue, Jan 11, 2022 at 03:00:23PM +0800, Jiasheng Jiang wrote:
> 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@iscas.ac.cn>
> ---
> fs/eventfd.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/eventfd.c b/fs/eventfd.c
> index 3627dd7d25db..5ec1d998f3ac 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) {
> + fd = ctx->id;
> + goto err;
> + }
Shouldn't this be 'ctx->id < 0'?
- Eric
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-12 6:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 7:00 [PATCH] fs/eventfd.c: Check error number after calling ida_simple_get Jiasheng Jiang
2022-01-12 6:35 ` Eric Biggers
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).