btrfs-progs: qgroup: check null when comparing paths

This patch fixes a bug that could occur when comparing paths in showing
qgroups list. Old code doesn't check it and the bug occurs when there is
stale qgroup and its path is null. Check whether it is null and return
without comparing paths.

Issue: #687
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Sidong Yang <realwakka@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Sidong Yang 2023-10-08 09:17:17 +00:00 committed by David Sterba
parent c1c4923a02
commit 8473ab8131

View File

@ -486,6 +486,14 @@ static int comp_entry_with_path(struct btrfs_qgroup *entry1,
if (ret)
goto out;
if (!p1) {
ret = p2 ? 1 : 0;
goto out;
} else if (!p2) {
ret = -1;
goto out;
}
while (*p1 && *p2) {
if (*p1 != *p2)
break;