All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix return value check of read_tree_block
@ 2012-03-21 23:23 Tsutomu Itoh
  0 siblings, 0 replies; only message in thread
From: Tsutomu Itoh @ 2012-03-21 23:23 UTC (permalink / raw)
  To: chris.mason; +Cc: linux-btrfs

read_tree_block() has the possibility of returning NULL.
So, the code in which it is checked whether the return value is
NULL is added.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
---
 fs/btrfs/print-tree.c |    1 +
 fs/btrfs/relocation.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index f38e452..9ea50b9 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -330,6 +330,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
 					btrfs_node_blockptr(c, i),
 					btrfs_level_size(root, level - 1),
 					btrfs_node_ptr_generation(c, i));
+		BUG_ON(!next);
 		if (btrfs_is_leaf(next) &&
 		   level != 1)
 			BUG();
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 8c1aae2..88221a8 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1884,7 +1884,7 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
 		bytenr = btrfs_node_blockptr(eb, path->slots[i]);
 		blocksize = btrfs_level_size(root, i - 1);
 		eb = read_tree_block(root, bytenr, blocksize, ptr_gen);
-		BUG_ON(btrfs_header_level(eb) != i - 1);
+		BUG_ON(!eb || btrfs_header_level(eb) != i - 1);
 		path->nodes[i - 1] = eb;
 		path->slots[i - 1] = 0;
 	}


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-03-21 23:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-21 23:23 [PATCH] Btrfs: fix return value check of read_tree_block Tsutomu Itoh

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.