From patchwork Mon Jul 9 21:18:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Hannemann X-Patchwork-Id: 1174871 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2D255DF235 for ; Mon, 9 Jul 2012 21:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752037Ab2GIVSi (ORCPT ); Mon, 9 Jul 2012 17:18:38 -0400 Received: from mail2.unitix.de ([176.9.2.175]:52905 "EHLO mail2.unitix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751549Ab2GIVSi (ORCPT ); Mon, 9 Jul 2012 17:18:38 -0400 Received: from kallisto.arndnet.de (77-216.eduroam.rwth-aachen.de [134.61.77.216]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail2.unitix.de (Postfix) with ESMTPSA id 8E5E9655D; Mon, 9 Jul 2012 23:18:33 +0200 (CEST) From: Arnd Hannemann To: linux-btrfs@vger.kernel.org Cc: chris.mason@fusionio.com, Arnd Hannemann Subject: [PATCH] btrfs-progs: btrfs-image: don't segfault if no root is found Date: Mon, 9 Jul 2012 23:18:28 +0200 Message-Id: <1341868709-7411-1-git-send-email-arnd@arndnet.de> X-Mailer: git-send-email 1.7.9.5 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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 --- 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,