linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Filipe Manana <fdmanana@gmail.com>
Cc: Xiyu Yang <xiyuyang19@fudan.edu.cn>, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>, Jeff Mahoney <jeffm@suse.com>,
	linux-btrfs <linux-btrfs@vger.kernel.org>,
	linux-kernel@vger.kernel.org, yuanxzhang@fudan.edu.cn,
	kjlu@umn.edu, Xin Tan <tanxin.ctf@gmail.com>
Subject: Re: [PATCH] btrfs: Fix refcnt leak in btrfs_recover_relocation
Date: Tue, 21 Apr 2020 00:32:29 +0200	[thread overview]
Message-ID: <20200420223229.GH18421@twin.jikos.cz> (raw)
In-Reply-To: <CAL3q7H4Yr2cdEgLWVAR2N_hPYEsra8yLA89meUMcvxH1VjtA6A@mail.gmail.com>

On Mon, Apr 20, 2020 at 06:35:56PM +0100, Filipe Manana wrote:
> On Mon, Apr 20, 2020 at 6:34 PM Filipe Manana <fdmanana@gmail.com> wrote:
> >
> > On Mon, Apr 20, 2020 at 6:50 AM Xiyu Yang <xiyuyang19@fudan.edu.cn> wrote:
> > >
> > > btrfs_recover_relocation() invokes btrfs_join_transaction(), which joins
> > > a btrfs_trans_handle object into transactions and returns a reference of
> > > it with increased refcount to "trans".
> > >
> > > When btrfs_recover_relocation() returns, "trans" becomes invalid, so the
> > > refcount should be decreased to keep refcount balanced.
> > >
> > > The reference counting issue happens in one exception handling path of
> > > btrfs_recover_relocation(). When read_fs_root() failed, the refcnt
> > > increased by btrfs_join_transaction() is not decreased, causing a refcnt
> > > leak.
> > >
> > > Fix this issue by calling btrfs_end_transaction() on this error path
> > > when read_fs_root() failed.
> > >
> > > Fixes: 79787eaab461 ("btrfs: replace many BUG_ONs with proper error
> > > handling")
> > > Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> > > Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> >
> > Reviewed-by: Filipe Manana <fdmanana@suse.com>
> >
> > Looks good, thanks.
> 
> Btw, the subject could be more clear.
> Instead of
> 
> "btrfs: Fix refcnt leak in btrfs_recover_relocation"
> 
> something like
> 
> "btrfs: fix transaction leak in ..."
> 
> David can probably fixup that when he picks the patch.

Yes, thanks, simple fixups are fine.

      reply	other threads:[~2020-04-20 22:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20  5:39 [PATCH] btrfs: Fix refcnt leak in btrfs_recover_relocation Xiyu Yang
2020-04-20 17:34 ` Filipe Manana
2020-04-20 17:35   ` Filipe Manana
2020-04-20 22:32     ` David Sterba [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=20200420223229.GH18421@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=fdmanana@gmail.com \
    --cc=jeffm@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=kjlu@umn.edu \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tanxin.ctf@gmail.com \
    --cc=xiyuyang19@fudan.edu.cn \
    --cc=yuanxzhang@fudan.edu.cn \
    /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;
as well as URLs for NNTP newsgroup(s).