summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-09-13 11:26:06 +0200
committerDavid Sterba <dsterba@suse.com>2016-10-03 11:33:15 +0200
commitea84d54121c228d0526404a97ac0cdd197f46ccb (patch)
tree70db7c8f7a6f17ea5a03f5543ca4253e9484d0b3
parent7e955fc856748573c3494dc5361bc482523c2fd2 (diff)
btrfs-progs: improve error handling in clone_inode_rec
Cleanup the rb_tree. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--cmds-check.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 327a6874..e53751c5 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -659,6 +659,7 @@ static struct inode_record *clone_inode_rec(struct inode_record *orig_rec)
struct inode_backref *tmp;
struct orphan_data_extent *src_orphan;
struct orphan_data_extent *dst_orphan;
+ struct rb_node *rb;
size_t size;
int ret;
@@ -691,10 +692,21 @@ static struct inode_record *clone_inode_rec(struct inode_record *orig_rec)
list_add_tail(&dst_orphan->list, &rec->orphan_extents);
}
ret = copy_file_extent_holes(&rec->holes, &orig_rec->holes);
- BUG_ON(ret < 0);
+ if (ret < 0)
+ goto cleanup_rb;
return rec;
+cleanup_rb:
+ rb = rb_first(&rec->holes);
+ while (rb) {
+ struct file_extent_hole *hole;
+
+ hole = rb_entry(rb, struct file_extent_hole, node);
+ rb = rb_next(rb);
+ free(hole);
+ }
+
cleanup:
if (!list_empty(&rec->backrefs))
list_for_each_entry_safe(orig, tmp, &rec->backrefs, list) {