public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs/eventfd.c: Check error number after calling ida_simple_get
Date: Tue, 11 Jan 2022 22:35:58 -0800	[thread overview]
Message-ID: <Yd52ziCZh7aJUTIU@sol.localdomain> (raw)
In-Reply-To: <20220111070023.566773-1-jiasheng@iscas.ac.cn>

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

      reply	other threads:[~2022-01-12  6:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yd52ziCZh7aJUTIU@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=jiasheng@iscas.ac.cn \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox