linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Hannemann <arnd@arndnet.de>
To: linux-btrfs@vger.kernel.org
Cc: chris.mason@fusionio.com, Arnd Hannemann <arnd@arndnet.de>
Subject: [PATCH] btrfs-progs: btrfs-image: don't segfault if no root is found
Date: Mon,  9 Jul 2012 23:18:28 +0200	[thread overview]
Message-ID: <1341868709-7411-1-git-send-email-arnd@arndnet.de> (raw)

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 --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,
-- 
1.7.9.5


                 reply	other threads:[~2012-07-09 21:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341868709-7411-1-git-send-email-arnd@arndnet.de \
    --to=arnd@arndnet.de \
    --cc=chris.mason@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).