diff mbox series

[v4,01/11] btrfs-progs: qgroup-verify: Avoid NULL pointer dereference for later silent qgroup repair

Message ID 20200318202148.14828-2-marcos@mpdesouza.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: mkfs: Quota support through -Q|--quota | expand

Commit Message

Marcos Paulo de Souza March 18, 2020, 8:21 p.m. UTC
From: Qu Wenruo <wqu@suse.com>

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>
---
 check/qgroup-verify.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/check/qgroup-verify.c b/check/qgroup-verify.c
index afe15acf..17c266d4 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;