aboutsummaryrefslogtreecommitdiffstats
path: root/qgroup-verify.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-07-15 16:12:00 +0200
committerDavid Sterba <dsterba@suse.com>2016-07-15 16:12:00 +0200
commit048f6274ff0c867363e9734e20f299e53b74ead3 (patch)
tree00bf9409941a29ca2a67520c2447c238160fbcf5 /qgroup-verify.c
parentaddd7e7f208d5dfcf369c60ff1cb4d2bf8b5ab30 (diff)
downloadbtrfs-progs-048f6274ff0c867363e9734e20f299e53b74ead3.tar.gz
btrfs-progs-048f6274ff0c867363e9734e20f299e53b74ead3.tar.xz
btrfs-progs-048f6274ff0c867363e9734e20f299e53b74ead3.zip
btrfs-progs: handle ulist_add errors in qgroup-verify
Resolves-coverity-id: 1364084 Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'qgroup-verify.c')
-rw-r--r--qgroup-verify.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/qgroup-verify.c b/qgroup-verify.c
index 3d96f1a..66eb870 100644
--- a/qgroup-verify.c
+++ b/qgroup-verify.c
@@ -318,10 +318,11 @@ FREE_RB_BASED_TREE(ref, free_ref_node);
/*
* Resolves all the possible roots for the ref at parent.
*/
-static void find_parent_roots(struct ulist *roots, u64 parent)
+static int find_parent_roots(struct ulist *roots, u64 parent)
{
struct ref *ref;
struct rb_node *node;
+ int ret;
/*
* Search the rbtree for the first ref with bytenr == parent.
@@ -348,16 +349,25 @@ static void find_parent_roots(struct ulist *roots, u64 parent)
do {
if (ref->root) {
- if (is_fstree(ref->root))
- ulist_add(roots, ref->root, 0, 0);
+ if (is_fstree(ref->root)) {
+ ret = ulist_add(roots, ref->root, 0, 0);
+ if (ret < 0)
+ goto out;
+ }
} else {
- find_parent_roots(roots, ref->parent);
+ ret = find_parent_roots(roots, ref->parent);
+ if (ret < 0)
+ goto out;
}
node = rb_next(node);
if (node)
ref = rb_entry(node, struct ref, bytenr_node);
} while (node && ref->bytenr == parent);
+
+ ret = 0;
+out:
+ return ret;
}
static int account_one_extent(struct ulist *roots, u64 bytenr, u64 num_bytes)
@@ -488,6 +498,7 @@ static int account_all_refs(int do_qgroups, u64 search_subvol)
struct rb_node *node;
u64 bytenr, num_bytes;
struct ulist *roots = ulist_alloc(0);
+ int ret;
node = rb_first(&by_bytenr);
while (node) {
@@ -511,7 +522,9 @@ static int account_all_refs(int do_qgroups, u64 search_subvol)
goto enomem;
}
} else {
- find_parent_roots(roots, ref->parent);
+ ret = find_parent_roots(roots, ref->parent);
+ if (ret < 0)
+ goto enomem;
}
/*