public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: fdmanana@kernel.org
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: fix double iput() on inode after an error during orphan cleanup
Date: Fri, 7 Jul 2023 13:26:15 -0700	[thread overview]
Message-ID: <20230707202615.GA2547493@zen> (raw)
In-Reply-To: <e20676cb8b120f12892f1e6ed80d91ec551ed533.1688403622.git.fdmanana@suse.com>

On Mon, Jul 03, 2023 at 06:15:30PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> At btrfs_orphan_cleanup(), if we were able to find the inode, we do an
> iput() on the inode, then if btrfs_drop_verity_items() succeeds and then
> either btrfs_start_transaction() or btrfs_del_orphan_item() fail, we do
> another iput() in the respective error paths, resulting in an extra iput()
> on the inode.
> 
> Fix this by setting inode to NULL after the first iput(), as iput()
> ignores a NULL inode pointer argument.
> 
> Fixes: a13bb2c03848 ("btrfs: add missing iputs on orphan cleanup failure")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
>  fs/btrfs/inode.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index dbbb67293e34..d919318d2498 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3728,6 +3728,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
>  			if (!ret) {
>  				ret = btrfs_drop_verity_items(BTRFS_I(inode));
>  				iput(inode);
> +				inode = NULL;
>  				if (ret)
>  					goto out;
>  			}
> -- 
> 2.34.1
> 

  reply	other threads:[~2023-07-07 20:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03 17:15 [PATCH 0/2] btrfs: fix error paths of btrfs_orphan_cleanup() fdmanana
2023-07-03 17:15 ` [PATCH 1/2] btrfs: fix double iput() on inode after an error during orphan cleanup fdmanana
2023-07-07 20:26   ` Boris Burkov [this message]
2023-07-03 17:15 ` [PATCH 2/2] btrfs: fix iput() on error pointer after " fdmanana
2023-07-07 20:26   ` Boris Burkov
2023-07-11 19:59 ` [PATCH 0/2] btrfs: fix error paths of btrfs_orphan_cleanup() David Sterba

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=20230707202615.GA2547493@zen \
    --to=boris@bur.io \
    --cc=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /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