public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Penglei Jiang <superman.xpt@gmail.com>
Cc: clm@fb.com, dsterba@suse.com, josef@toxicpanda.com,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: fix the resource leak issue in btrfs_iget()
Date: Tue, 22 Apr 2025 05:42:44 +0930	[thread overview]
Message-ID: <367f977b-9c74-486f-9a27-75a8a7ea50ef@gmx.com> (raw)
In-Reply-To: <20250421154029.2399-1-superman.xpt@gmail.com>



在 2025/4/22 01:10, Penglei Jiang 写道:
> When btrfs_iget() returns an error, it does not use iget_failed() to mark
> and release the inode. Now, we add the missing iget_failed() call.
> 
> Fixes: 7c855e16ab72 ("btrfs: remove conditional path allocation in btrfs_read_locked_inode()")
> Reported-by: Penglei Jiang <superman.xpt@gmail.com>
> Signed-off-by: Penglei Jiang <superman.xpt@gmail.com>
> ---
> V1 -> V2: Fixed the issue with multiple calls to btrfs_iget()

Looks good to me.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> 
>   fs/btrfs/inode.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index cc67d1a2d611..1cbf92ca748d 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -5681,8 +5681,10 @@ struct btrfs_inode *btrfs_iget(u64 ino, struct btrfs_root *root)
>   		return inode;
>   
>   	path = btrfs_alloc_path();
> -	if (!path)
> +	if (!path) {
> +		iget_failed(&inode->vfs_inode);
>   		return ERR_PTR(-ENOMEM);
> +	}
>   
>   	ret = btrfs_read_locked_inode(inode, path);
>   	btrfs_free_path(path);

  reply	other threads:[~2025-04-21 20:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21 10:32 [PATCH] btrfs: fix the resource leak issue in btrfs_iget() Penglei Jiang
2025-04-21 10:42 ` Qu Wenruo
2025-04-21 15:40   ` [PATCH v2] " Penglei Jiang
2025-04-21 20:12     ` Qu Wenruo [this message]
2025-04-22  4:09     ` Qu Wenruo

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=367f977b-9c74-486f-9a27-75a8a7ea50ef@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=superman.xpt@gmail.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