From: Ilya Dryomov Date: Mon, 12 Dec 2011 18:00:25 +0000 (+0200) Subject: Btrfs-progs: fail gracefully on error from open_ctree() X-Git-Tag: upstream/0.20.rc1~62 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5734e88370bc7bfe83e9d33b6f51c905a8fb91e;p=platform%2Fupstream%2Fbtrfs-progs.git Btrfs-progs: fail gracefully on error from open_ctree() Error checking block got moved mistakenly exposing us to a potential segmentation fault. Signed-off-by: Ilya Dryomov --- diff --git a/mkfs.c b/mkfs.c index e3ced19..2085ae1 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1328,7 +1328,12 @@ int main(int ac, char **av) fprintf(stderr, "error during mkfs %d\n", ret); exit(1); } + root = open_ctree(file, 0, O_RDWR); + if (!root) { + fprintf(stderr, "ctree init failed\n"); + exit(1); + } root->fs_info->alloc_start = alloc_start; ret = make_root_dir(root, mixed); @@ -1343,10 +1348,6 @@ int main(int ac, char **av) goto raid_groups; btrfs_register_one_device(file); - if (!root) { - fprintf(stderr, "ctree init failed\n"); - return -1; - } zero_end = 1; while(ac-- > 0) {