Skip to content

Commit f03e274

Browse files
pchelkin91kdave
authored andcommitted
btrfs: ref-verify: free ref cache before clearing mount opt
As clearing REF_VERIFY mount option indicates there were some errors in a ref-verify process, a ref cache is not relevant anymore and should be freed. btrfs_free_ref_cache() requires REF_VERIFY option being set so call it just before clearing the mount option. Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Reported-by: syzbot+be14ed7728594dc8bd42@syzkaller.appspotmail.com Fixes: fd708b8 ("Btrfs: add a extent ref verify tool") CC: stable@vger.kernel.org # 5.4+ Closes: https://lore.kernel.org/lkml/000000000000e5a65c05ee832054@google.com/ Reported-by: syzbot+c563a3c79927971f950f@syzkaller.appspotmail.com Closes: https://lore.kernel.org/lkml/0000000000007fe09705fdc6086c@google.com/ Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 6ff09b6 commit f03e274

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/btrfs/ref-verify.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,10 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
889889
out_unlock:
890890
spin_unlock(&fs_info->ref_verify_lock);
891891
out:
892-
if (ret)
892+
if (ret) {
893+
btrfs_free_ref_cache(fs_info);
893894
btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
895+
}
894896
return ret;
895897
}
896898

@@ -1021,8 +1023,8 @@ int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info)
10211023
}
10221024
}
10231025
if (ret) {
1024-
btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
10251026
btrfs_free_ref_cache(fs_info);
1027+
btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
10261028
}
10271029
btrfs_free_path(path);
10281030
return ret;

0 commit comments

Comments
 (0)