From: Dan Carpenter <dan.carpenter@oracle.com>
To: dsterba@suse.cz, Chris Mason <clm@fb.com>,
Josef Bacik <jbacik@fb.com>, David Sterba <dsterba@suse.com>,
Qu Wenruo <wqu@suse.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Mike Rapoport <rppt@linux.ibm.com>,
Bjorn Helgaas <bhelgaas@google.com>,
linux-btrfs@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: Fix btrfs_find_create_tree_block() testing
Date: Tue, 3 Dec 2019 21:46:01 +0300 [thread overview]
Message-ID: <20191203184601.GI1787@kadam> (raw)
In-Reply-To: <20191203184039.GU2734@twin.jikos.cz>
On Tue, Dec 03, 2019 at 07:40:39PM +0100, David Sterba wrote:
> On Tue, Dec 03, 2019 at 02:24:58PM +0300, Dan Carpenter wrote:
> > The btrfs_find_create_tree_block() uses alloc_test_extent_buffer() for
> > testing and alloc_extent_buffer() for production. The problem is that
> > the test code returns NULL and the production code returns error
> > pointers. The callers only check for error pointers.
> >
> > I have changed alloc_test_extent_buffer() to return error pointers and
> > updated the two callers which use it directly.
> >
> > Fixes: faa2dbf004e8 ("Btrfs: add sanity tests for new qgroup accounting code")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> I edited the changelog because btrfs_find_create_tree_block is
> misleading and seems to be unrelated to the actual fix that's just for
> alloc_test_extent_buffer. Patch added to misc-next, thanks.
The bug is in btrfs_find_create_tree_block()
fs/btrfs/disk-io.c
1046 struct extent_buffer *btrfs_find_create_tree_block(
1047 struct btrfs_fs_info *fs_info,
1048 u64 bytenr)
1049 {
1050 if (btrfs_is_testing(fs_info))
1051 return alloc_test_extent_buffer(fs_info, bytenr);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
NULL
1052 return alloc_extent_buffer(fs_info, bytenr);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error pointers.
1053 }
None of the callers of btrfs_find_create_tree_block() check for NULL.
regards,
dan carpenter
next prev parent reply other threads:[~2019-12-03 18:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-03 9:33 [PATCH] btrfs: Fix btrfs_find_create_tree_block() testing Dan Carpenter
2019-12-03 11:04 ` Mike Rapoport
2019-12-03 11:24 ` [PATCH v2] " Dan Carpenter
2019-12-03 18:40 ` David Sterba
2019-12-03 18:46 ` Dan Carpenter [this message]
2019-12-03 19:06 ` 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=20191203184601.GI1787@kadam \
--to=dan.carpenter@oracle.com \
--cc=bhelgaas@google.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=dsterba@suse.cz \
--cc=jbacik@fb.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=rppt@linux.ibm.com \
--cc=sakari.ailus@linux.intel.com \
--cc=wqu@suse.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;
as well as URLs for NNTP newsgroup(s).