mirror of
https://github.com/torvalds/linux.git
synced 2026-09-11 20:13:02 +02:00
btrfs: tests: do not touch page cache if root/inode allocation failed
Inside test_find_delalloc() of extent-io-tests.c, if we fail to allocate a dummy root or the test inode, we go to out label to clean up. But at that stage, @inode is still NULL and we will call process_page_range() to access the page cache of the inode, this will cause NULL pointer dereference. This is a very minor bug, as it only affects selftests which are not compiled in by default for most distros, and very hard to trigger. Fix it by adding a new out_root_info label to handle root and inode allocation failure. This is a pre-existing bug reported by Sashiko while reviewing another patch. Link: https://sashiko.dev/#/patchset/cover.1786095309.git.wqu%40suse.com Reviewed-by: Boris Burkov <boris@bur.io> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
2acb9f3d1c
commit
0c1032c8c3
|
|
@ -133,14 +133,14 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
|
|||
if (IS_ERR(root)) {
|
||||
test_std_err(TEST_ALLOC_ROOT);
|
||||
ret = PTR_ERR(root);
|
||||
goto out;
|
||||
goto out_root_info;
|
||||
}
|
||||
|
||||
inode = btrfs_new_test_inode();
|
||||
if (!inode) {
|
||||
test_std_err(TEST_ALLOC_INODE);
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
goto out_root_info;
|
||||
}
|
||||
tmp = &BTRFS_I(inode)->io_tree;
|
||||
BTRFS_I(inode)->root = root;
|
||||
|
|
@ -333,6 +333,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
|
|||
process_page_range(inode, 0, total_dirty - 1,
|
||||
PROCESS_UNLOCK | PROCESS_RELEASE);
|
||||
iput(inode);
|
||||
out_root_info:
|
||||
btrfs_free_dummy_root(root);
|
||||
btrfs_free_dummy_fs_info(fs_info);
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user