]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
btrfs: check NULL or not
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>
Wed, 5 Jan 2011 02:32:22 +0000 (02:32 +0000)
committerChris Mason <chris.mason@oracle.com>
Sun, 16 Jan 2011 16:30:20 +0000 (11:30 -0500)
Should check if functions returns NULL or not.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/ctree.c
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c

index 99599f1c15549791a2f3cb2d560c579be8c7b920..b5baff0dccfec40c360397c0d1e47380aea51ae2 100644 (file)
@@ -2516,6 +2516,9 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
        btrfs_assert_tree_locked(path->nodes[1]);
 
        right = read_node_slot(root, upper, slot + 1);
+       if (right == NULL)
+               return 1;
+
        btrfs_tree_lock(right);
        btrfs_set_lock_blocking(right);
 
@@ -2766,6 +2769,9 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
        btrfs_assert_tree_locked(path->nodes[1]);
 
        left = read_node_slot(root, path->nodes[1], slot - 1);
+       if (left == NULL)
+               return 1;
+
        btrfs_tree_lock(left);
        btrfs_set_lock_blocking(left);
 
index f9efb68fc2e39860a8184bad1b296273fc010b7d..a0c37b2ee9edef1cc226551655ecbe9a1bc9e3ee 100644 (file)
@@ -353,6 +353,10 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
        WARN_ON(len == 0);
 
        eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS);
+       if (eb == NULL) {
+               WARN_ON(1);
+               goto out;
+       }
        ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE,
                                             btrfs_header_generation(eb));
        BUG_ON(ret);
@@ -427,6 +431,10 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
        WARN_ON(len == 0);
 
        eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS);
+       if (eb == NULL) {
+               ret = -EIO;
+               goto out;
+       }
 
        found_start = btrfs_header_bytenr(eb);
        if (found_start != start) {
index f1d1981289599b561e01eeecd8b1f48c7e44df60..8b8d3d99ae68cbaa09a3369633bf7c2f48c9f3d7 100644 (file)
@@ -3075,6 +3075,8 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,
 #endif
 
        eb = kmem_cache_zalloc(extent_buffer_cache, mask);
+       if (eb == NULL)
+               return NULL;
        eb->start = start;
        eb->len = len;
        spin_lock_init(&eb->lock);