[01/11] btrfs-progs: qgroup-verify: Avoid NULL pointer dereference for later silent qgroup repair
diff mbox series

Message ID 20180807081938.21348-2-wqu@suse.com
State New
Headers show
Series
  • btrfs-progs: mkfs: Quota support through -Q|--quota
Related show

Commit Message

Qu Wenruo Aug. 7, 2018, 8:19 a.m. UTC
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 <wqu@suse.com>
---
 qgroup-verify.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/qgroup-verify.c b/qgroup-verify.c
index f5885589f02c..9b509abb78fd 100644
--- a/qgroup-verify.c
+++ b/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;