btrfs: fix ulist leaks in error paths of qgroup self tests
[platform/kernel/linux-rpi.git] / fs / btrfs / tests / qgroup-tests.c
index 19ba7d5..a374b62 100644 (file)
@@ -232,8 +232,10 @@ static int test_no_shared_qgroup(struct btrfs_root *root,
 
        ret = insert_normal_tree_ref(root, nodesize, nodesize, 0,
                                BTRFS_FS_TREE_OBJECTID);
-       if (ret)
+       if (ret) {
+               ulist_free(old_roots);
                return ret;
+       }
 
        ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots, false);
        if (ret) {
@@ -266,8 +268,10 @@ static int test_no_shared_qgroup(struct btrfs_root *root,
        }
 
        ret = remove_extent_item(root, nodesize, nodesize);
-       if (ret)
+       if (ret) {
+               ulist_free(old_roots);
                return -EINVAL;
+       }
 
        ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots, false);
        if (ret) {
@@ -329,8 +333,10 @@ static int test_multiple_refs(struct btrfs_root *root,
 
        ret = insert_normal_tree_ref(root, nodesize, nodesize, 0,
                                BTRFS_FS_TREE_OBJECTID);
-       if (ret)
+       if (ret) {
+               ulist_free(old_roots);
                return ret;
+       }
 
        ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots, false);
        if (ret) {
@@ -362,8 +368,10 @@ static int test_multiple_refs(struct btrfs_root *root,
 
        ret = add_tree_ref(root, nodesize, nodesize, 0,
                        BTRFS_FIRST_FREE_OBJECTID);
-       if (ret)
+       if (ret) {
+               ulist_free(old_roots);
                return ret;
+       }
 
        ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots, false);
        if (ret) {
@@ -401,8 +409,10 @@ static int test_multiple_refs(struct btrfs_root *root,
 
        ret = remove_extent_ref(root, nodesize, nodesize, 0,
                                BTRFS_FIRST_FREE_OBJECTID);
-       if (ret)
+       if (ret) {
+               ulist_free(old_roots);
                return ret;
+       }
 
        ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots, false);
        if (ret) {