All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.cz>
Subject: [PATCH 03/12] btrfs: fix dereference before check
Date: Fri, 22 Apr 2011 11:41:24 +0200	[thread overview]
Message-ID: <8927a99072750c65ba0c3379d6663913cae8d258.1303398927.git.dsterba@suse.cz> (raw)
In-Reply-To: <cover.1303398927.git.dsterba@suse.cz>

The superblock's ->s_fs_info is properly set in btrfs_fill_super, after
a call to open_ctree, which derefereces it before check. Although
tree_root is set via btrfs_set_super, let's be defensive and leave the
check in place.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/disk-io.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 8f07c86..5e5d07c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1611,7 +1611,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 	struct btrfs_root *csum_root = kzalloc(sizeof(struct btrfs_root),
 						 GFP_NOFS);
 	struct btrfs_root *tree_root = btrfs_sb(sb);
-	struct btrfs_fs_info *fs_info = tree_root->fs_info;
+	struct btrfs_fs_info *fs_info = NULL;
 	struct btrfs_root *chunk_root = kzalloc(sizeof(struct btrfs_root),
 						GFP_NOFS);
 	struct btrfs_root *dev_root = kzalloc(sizeof(struct btrfs_root),
@@ -1623,11 +1623,12 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 
 	struct btrfs_super_block *disk_super;
 
-	if (!extent_root || !tree_root || !fs_info ||
+	if (!extent_root || !tree_root || !tree_root->fs_info ||
 	    !chunk_root || !dev_root || !csum_root) {
 		err = -ENOMEM;
 		goto fail;
 	}
+	fs_info = tree_root->fs_info;
 
 	ret = init_srcu_struct(&fs_info->subvol_srcu);
 	if (ret) {
-- 
1.7.5.rc3


  parent reply	other threads:[~2011-04-22  9:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-22  9:41 [PATCH 00/12] Cleanups, cruft removal David Sterba
2011-04-22  9:41 ` [PATCH 01/12] btrfs: rename variables clashing with global function names David Sterba
2011-04-22  9:41 ` [PATCH 02/12] btrfs: remove nested duplicate variable declarations David Sterba
2011-04-22  9:41 ` David Sterba [this message]
2011-04-22  9:41 ` [PATCH 04/12] btrfs: unify checking of IS_ERR and null David Sterba
2011-04-22  9:41 ` [PATCH 05/12] btrfs: remove useless mutex lock/unlock sequences David Sterba
2011-04-25  6:25   ` Tsutomu Itoh
2011-04-25 12:12     ` Chris Mason
2011-04-29 16:34       ` David Sterba
2011-05-02 13:49   ` [PATCH] btrfs: Document a mutex lock/unlock sequence David Sterba
2011-04-22  9:41 ` [PATCH 06/12] btrfs: make functions static when possible David Sterba
2011-04-22  9:42 ` [PATCH 07/12] btrfs: drop unused argument from extent_io_tree_init David Sterba
2011-04-22  9:42 ` [PATCH 08/12] btrfs: drop unused parameter from extent_map_tree_init David Sterba
2011-04-22  9:42 ` [PATCH 09/12] btrfs: drop gfp parameter from alloc_extent_map David Sterba
2011-04-22  9:42 ` [PATCH 10/12] btrfs: drop gfp parameter from find_extent_buffer David Sterba
2011-04-22  9:43 ` [PATCH 11/12] btrfs: drop gfp parameter from alloc_extent_buffer David Sterba
2011-04-22  9:43 ` [PATCH 12/12] btrfs: drop unused parameter from btrfs_release_path David Sterba
2011-05-02 14:01 ` [PATCH 00/12] Cleanups, cruft removal David Sterba

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=8927a99072750c65ba0c3379d6663913cae8d258.1303398927.git.dsterba@suse.cz \
    --to=dsterba@suse.cz \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.