On Tue, Dec 03, 2019 at 09:46:01PM +0300, Dan Carpenter wrote: > 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@xxxxxxxxxx> > > > > 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. I see, though my view is a bug in alloc_test_extent_buffer that should follow alloc_extent_buffer semantics, and this gets fixed. I'll update the changelog again, makes sense to mention that it namely affects btrfs_find_create_tree_block.