public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Baokun Li <libaokun1@huawei.com>
To: Julian Sun <sunjunchao2870@gmail.com>, <linux-ext4@vger.kernel.org>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>, <jack@suse.cz>,
	Yang Erkun <yangerkun@huawei.com>
Subject: Re: [PATCH] ext4: remove unnecessary checks for __GFP_NOFAIL allocation.
Date: Fri, 28 Feb 2025 16:44:42 +0800	[thread overview]
Message-ID: <9be439b3-fd43-4a4b-96e5-0d0ec5fb1509@huawei.com> (raw)
In-Reply-To: <20250228081126.2634480-1-sunjunchao2870@gmail.com>

On 2025/2/28 16:11, Julian Sun wrote:
> The __GFP_NOFAIL flag ensures that allocation will not fail.
> So remove the unnecessary checks.
Actually, even with __GFP_NOFAIL set, kcalloc() can still return NULL,
such as when the input parameters overflow.


Baokun
>
> Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
> ---
>   fs/ext4/extents.c | 4 ----
>   1 file changed, 4 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index a07a98a4b97a..95debd5d6506 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -2940,10 +2940,6 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
>   	} else {
>   		path = kcalloc(depth + 1, sizeof(struct ext4_ext_path),
>   			       GFP_NOFS | __GFP_NOFAIL);
> -		if (path == NULL) {
> -			ext4_journal_stop(handle);
> -			return -ENOMEM;
> -		}
>   		path[0].p_maxdepth = path[0].p_depth = depth;
>   		path[0].p_hdr = ext_inode_hdr(inode);
>   		i = 0;



  reply	other threads:[~2025-02-28  8:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28  8:11 [PATCH] ext4: remove unnecessary checks for __GFP_NOFAIL allocation Julian Sun
2025-02-28  8:44 ` Baokun Li [this message]
2025-02-28  9:30   ` Julian Sun
2025-02-28 13:34     ` Theodore Ts'o
2025-03-01 14:32       ` Julian Sun
2025-02-28 10:19 ` Zhang Yi

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=9be439b3-fd43-4a4b-96e5-0d0ec5fb1509@huawei.com \
    --to=libaokun1@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sunjunchao2870@gmail.com \
    --cc=tytso@mit.edu \
    --cc=yangerkun@huawei.com \
    /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