diff mbox

btrfs-progs: btrfs-image: don't segfault if no root is found

Message ID 1341868709-7411-1-git-send-email-arnd@arndnet.de (mailing list archive)
State New, archived
Headers show

Commit Message

Arnd Hannemann July 9, 2012, 9:18 p.m. UTC
Error reporting is already done, so just return if root is NULL,
instead of segfaulting:

Program received signal SIGSEGV, Segmentation fault.
0x000000000042cd34 in create_metadump (input=0x7fffffffe847 "/usr/share", out=0x63e010, num_threads=0, compress_level=0)
    at btrfs-image.c:494
494		BUG_ON(root->nodesize != root->leafsize);
    at btrfs-image.c:494

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
---
 btrfs-image.c |    2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/btrfs-image.c b/btrfs-image.c
index f2bbcc8..fec51d8 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -491,6 +491,8 @@  static int create_metadump(const char *input, FILE *out, int num_threads,
 	int ret;
 
 	root = open_ctree(input, 0, 0);
+	if (!root)
+		return 1;
 	BUG_ON(root->nodesize != root->leafsize);
 
 	ret = metadump_init(&metadump, root, out, num_threads,