Commit 923eb523 authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by David Sterba

btrfs: use free_root_extent_buffer to free root

In btrfs_put_root() we're freeing a btrfs_root's 'node' and 'commit_root'
extent buffers manually via kfree(), while we're using
free_root_extent_buffers() in the free_root_pointers() function above.

free_root_extent_buffers() also NULLs the pointers after freeing, which
mitigates potential double frees.
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 4e9d0d01
...@@ -2001,8 +2001,7 @@ void btrfs_put_root(struct btrfs_root *root) ...@@ -2001,8 +2001,7 @@ void btrfs_put_root(struct btrfs_root *root)
if (root->anon_dev) if (root->anon_dev)
free_anon_bdev(root->anon_dev); free_anon_bdev(root->anon_dev);
btrfs_drew_lock_destroy(&root->snapshot_lock); btrfs_drew_lock_destroy(&root->snapshot_lock);
free_extent_buffer(root->node); free_root_extent_buffers(root);
free_extent_buffer(root->commit_root);
kfree(root->free_ino_ctl); kfree(root->free_ino_ctl);
kfree(root->free_ino_pinned); kfree(root->free_ino_pinned);
#ifdef CONFIG_BTRFS_DEBUG #ifdef CONFIG_BTRFS_DEBUG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment