linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs-progs: fail gracefully on error from open_ctree()
@ 2011-11-01 21:47 Ilya Dryomov
  2011-12-12 14:40 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Ilya Dryomov @ 2011-11-01 21:47 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Chris Mason, Hugo Mills, idryomov

Error checking block got moved mistakenly exposing us to a potential
segmentation fault.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 mkfs.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/mkfs.c b/mkfs.c
index e3ced19..a6f6b1f 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");
+		return -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) {
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-12 18:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-01 21:47 [PATCH] Btrfs-progs: fail gracefully on error from open_ctree() Ilya Dryomov
2011-12-12 14:40 ` David Sterba
2011-12-12 18:07   ` Ilya Dryomov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).