btrfs-progs: qgroup-verify: avoid NULL pointer dereference for later silent qgroup repair

Commit 078e9a1cc9 ("btrfs-progs: check: enhanced progress indicator")
introduced @qgroup_item_count for progress indicator.

However since we will later introduce silent qgroup rescan
functionality, the @qgroup_item_count pointer can be NULL.

So check if @qgroup_item_count is NULL before accessing it.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2020-03-18 17:21:38 -03:00 committed by David Sterba
parent 2df82a2da6
commit b917a4bd93
1 changed files with 2 additions and 1 deletions

View File

@ -743,7 +743,8 @@ static int travel_tree(struct btrfs_fs_info *info, struct btrfs_root *root,
*/ */
nr = btrfs_header_nritems(eb); nr = btrfs_header_nritems(eb);
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
(*qgroup_item_count)++; if (qgroup_item_count)
(*qgroup_item_count)++;
new_bytenr = btrfs_node_blockptr(eb, i); new_bytenr = btrfs_node_blockptr(eb, i);
new_num_bytes = info->nodesize; new_num_bytes = info->nodesize;