From 8473ab813103f7b109eb53eea9b7980fb973783f Mon Sep 17 00:00:00 2001 From: Sidong Yang Date: Sun, 8 Oct 2023 09:17:17 +0000 Subject: [PATCH] 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 Signed-off-by: Sidong Yang Signed-off-by: David Sterba --- cmds/qgroup.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmds/qgroup.c b/cmds/qgroup.c index d9104d1a..265c4910 100644 --- a/cmds/qgroup.c +++ b/cmds/qgroup.c @@ -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;