From b917a4bd93eeb99f93612d6432508215458eb211 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 18 Mar 2020 17:21:38 -0300 Subject: [PATCH] btrfs-progs: qgroup-verify: avoid NULL pointer dereference for later silent qgroup repair Commit 078e9a1cc973 ("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 Signed-off-by: David Sterba --- check/qgroup-verify.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check/qgroup-verify.c b/check/qgroup-verify.c index 685370d6..1fcc3eb4 100644 --- a/check/qgroup-verify.c +++ b/check/qgroup-verify.c @@ -743,7 +743,8 @@ static int travel_tree(struct btrfs_fs_info *info, struct btrfs_root *root, */ nr = btrfs_header_nritems(eb); for (i = 0; i < nr; i++) { - (*qgroup_item_count)++; + if (qgroup_item_count) + (*qgroup_item_count)++; new_bytenr = btrfs_node_blockptr(eb, i); new_num_bytes = info->nodesize;