From patchwork Wed Apr 7 02:04:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: R Harshavardhana X-Patchwork-Id: 90913 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o372CWEp013950 for ; Wed, 7 Apr 2010 02:12:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756970Ab0DGCMb (ORCPT ); Tue, 6 Apr 2010 22:12:31 -0400 Received: from zp3.zcs.datasyncintra.net ([208.88.241.29]:4843 "EHLO zp3.zcs.datasyncintra.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756507Ab0DGCMa (ORCPT ); Tue, 6 Apr 2010 22:12:30 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 07 Apr 2010 02:12:33 +0000 (UTC) X-Greylist: delayed 467 seconds by postgrey-1.27 at vger.kernel.org; Tue, 06 Apr 2010 22:12:30 EDT Received: from localhost (localhost [127.0.0.1]) by zp3.zcs.datasyncintra.net (Postfix) with ESMTP id 629342066 for ; Tue, 6 Apr 2010 21:04:43 -0500 (CDT) X-Virus-Scanned: amavisd-new at zp3.zcs.datasyncintra.net Received: from zp3.zcs.datasyncintra.net ([127.0.0.1]) by localhost (zp3.zcs.datasyncintra.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wQgRCo0BJ+Kp for ; Tue, 6 Apr 2010 21:04:43 -0500 (CDT) Received: from localhost.localdomain (adsl-99-160-131-163.dsl.pltn13.sbcglobal.net [99.160.131.163]) (Authenticated sender: harsha@gluster.com) by zp3.zcs.datasyncintra.net (Postfix) with ESMTPSA id AF424205E for ; Tue, 6 Apr 2010 21:04:42 -0500 (CDT) From: Harshavardhana To: linux-btrfs@vger.kernel.org Subject: [PATCH] btfs-progs: Add null pointer checks Date: Tue, 6 Apr 2010 19:04:37 -0700 Message-Id: <1270605877-26779-1-git-send-email-harsha@gluster.com> X-Mailer: git-send-email 1.6.6.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org diff --git a/btrfs-image.c b/btrfs-image.c index f2bbcc8..b3cafbb 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -491,6 +491,11 @@ static int create_metadump(const char *input, FILE *out, int num_threads, int ret; root = open_ctree(input, 0, 0); + if (!root) { + fprintf (stderr, "unable to open ctree for %s\n", input); + return 1; + } + BUG_ON(root->nodesize != root->leafsize); ret = metadump_init(&metadump, root, out, num_threads, diff --git a/btrfstune.c b/btrfstune.c index 47830c5..d2c3d51 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -108,6 +108,13 @@ int main(int argc, char *argv[]) root = open_ctree(device, 0, 1); + /* root is NULL if btrfs not found */ + if (!root) { + fprintf(stderr, "Unable to open ctree for device: %s\n", + device); + return 1; + } + if (seeding_flag) { ret = update_seeding_flag(root, seeding_value); if (!ret)