summaryrefslogtreecommitdiff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorDaniel J Blueman <daniel.blueman@gmail.com>2011-06-23 23:01:01 +0800
committerDavid Sterba <dsterba@suse.cz>2011-10-20 18:10:50 +0200
commit068132bad1de70f85f5f6d12c36d64f8f7848d92 (patch)
tree7e4a4a164b8153cf463662fbc2ce00f5671f4fa6 /fs/btrfs
parent60d2adbb1e7fee1cb4bc67f70bd0bd8ace7b6c3c (diff)
downloadlinux-stable-068132bad1de70f85f5f6d12c36d64f8f7848d92.tar.gz
linux-stable-068132bad1de70f85f5f6d12c36d64f8f7848d92.tar.bz2
linux-stable-068132bad1de70f85f5f6d12c36d64f8f7848d92.zip
btrfs: fix oops on failure path
If lookup_extent_backref fails, path->nodes[0] reasonably could be null along with other callers of btrfs_print_leaf, so ensure we have a valid extent buffer before dereferencing. Signed-off-by: Daniel J Blueman <daniel.blueman@gmail.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/print-tree.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index fb2605d998e9..f38e452486b8 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -158,8 +158,7 @@ static void print_extent_ref_v0(struct extent_buffer *eb, int slot)
void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
{
int i;
- u32 type;
- u32 nr = btrfs_header_nritems(l);
+ u32 type, nr;
struct btrfs_item *item;
struct btrfs_root_item *ri;
struct btrfs_dir_item *di;
@@ -172,6 +171,11 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
struct btrfs_key key;
struct btrfs_key found_key;
+ if (!l)
+ return;
+
+ nr = btrfs_header_nritems(l);
+
printk(KERN_INFO "leaf %llu total ptrs %d free space %d\n",
(unsigned long long)btrfs_header_bytenr(l), nr,
btrfs_leaf_free_space(root, l));