diff options
author | Jia-Ju Bai <baijiaju1990@gmail.com> | 2022-03-24 16:44:54 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-04-06 01:50:47 +0300 |
commit | 168a2f776b9762f4021421008512dd7ab7474df1 (patch) | |
tree | 8463e20885238b31b7c766b7dac7200f40c7b28f /fs/btrfs/dev-replace.c | |
parent | 760e69c4c2e2f475a812bdd414b62758215ce9cb (diff) | |
download | linux-168a2f776b9762f4021421008512dd7ab7474df1.tar.xz |
btrfs: fix root ref counts in error handling in btrfs_get_root_ref
In btrfs_get_root_ref(), when btrfs_insert_fs_root() fails,
btrfs_put_root() can happen for two reasons:
- the root already exists in the tree, in that case it returns the
reference obtained in btrfs_lookup_fs_root()
- another error so the cleanup is done in the fail label
Calling btrfs_put_root() unconditionally would lead to double decrement
of the root reference possibly freeing it in the second case.
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Fixes: bc44d7c4b2b1 ("btrfs: push btrfs_grab_fs_root into btrfs_get_fs_root")
CC: stable@vger.kernel.org # 5.10+
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/dev-replace.c')
0 files changed, 0 insertions, 0 deletions