Skip to content

Commit 68c94e5

Browse files
lorddoskiaskdave
authored andcommitted
btrfs: Transpose btrfs_close_devices/btrfs_mapping_tree_free in close_ctree
Following the introduction of the alloc_state tree, some of the callees of btrfs_mapping_tree_free will have to interact with the btrfs_device of the constituent devices. Enable this by moving the code responsible for freeing devices after the last user (btrfs_mapping_tree_free). Otherwise the kernel could crash due to use-after-free. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 8e75fd8 commit 68c94e5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/btrfs/disk-io.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4040,8 +4040,8 @@ void close_ctree(struct btrfs_fs_info *fs_info)
40404040
btrfsic_unmount(fs_info->fs_devices);
40414041
#endif
40424042

4043-
btrfs_close_devices(fs_info->fs_devices);
40444043
btrfs_mapping_tree_free(&fs_info->mapping_tree);
4044+
btrfs_close_devices(fs_info->fs_devices);
40454045

40464046
percpu_counter_destroy(&fs_info->dirty_metadata_bytes);
40474047
percpu_counter_destroy(&fs_info->delalloc_bytes);

0 commit comments

Comments
 (0)