Add close_ctree()s before the "returns" on errors after open_ctree()
Signed-off-by: Gui Hecheng <guihc.fnst@xxxxxxxxxxxxxx>
---
cmds-check.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/cmds-check.c b/cmds-check.c
index 2911af0..81f65a3 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6460,6 +6460,7 @@ int cmd_check(int argc, char **argv)
!extent_buffer_uptodate(info->dev_root->node) ||
!extent_buffer_uptodate(info->chunk_root->node)) {
fprintf(stderr, "Critical roots corrupted, unable to fsck the FS\n");
+ close_ctree(info->fs_root);
return -EIO;
}
@@ -6467,11 +6468,14 @@ int cmd_check(int argc, char **argv)
if (init_extent_tree) {
printf("Creating a new extent tree\n");
ret = reinit_extent_tree(info);
- if (ret)
+ if (ret) {
+ close_ctree(root);
return ret;
+ }
}
if (!extent_buffer_uptodate(info->extent_root->node)) {
fprintf(stderr, "Critical roots corrupted, unable to fsck the FS\n");
+ close_ctree(root);
return -EIO;
}
@@ -6483,12 +6487,14 @@ int cmd_check(int argc, char **argv)
trans = btrfs_start_transaction(info->csum_root, 1);
if (IS_ERR(trans)) {
fprintf(stderr, "Error starting transaction\n");
+ close_ctree(root);
return PTR_ERR(trans);
}
ret = btrfs_fsck_reinit_root(trans, info->csum_root, 0);
if (ret) {
fprintf(stderr, "crc root initialization failed\n");
+ close_ctree(root);
return -EIO;
}
--
1.8.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html