diff options
author | Tsutomu Itoh <t-itoh@jp.fujitsu.com> | 2011-02-01 04:17:35 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-02-01 07:16:37 -0500 |
commit | 5df67083488ccbad925f583b698ab38f8629a016 (patch) | |
tree | ec428f27f1b72c4d8e284831d4bef8894b2b8457 | |
parent | c87fb6fdcaf7560940b31a0c78c3e6370e3433cf (diff) |
btrfs: checking NULL or not in some functions
Because NULL is returned when the memory allocation fails,
it is checked whether it is NULL.
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r-- | fs/btrfs/extent-tree.c | 2 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 2 | ||||
-rw-r--r-- | fs/btrfs/tree-log.c | 6 |
3 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index f96641a93fc9..9de4ff03882a 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -6496,6 +6496,8 @@ static noinline int relocate_inode_pages(struct inode *inode, u64 start, | |||
6496 | int ret = 0; | 6496 | int ret = 0; |
6497 | 6497 | ||
6498 | ra = kzalloc(sizeof(*ra), GFP_NOFS); | 6498 | ra = kzalloc(sizeof(*ra), GFP_NOFS); |
6499 | if (!ra) | ||
6500 | return -ENOMEM; | ||
6499 | 6501 | ||
6500 | mutex_lock(&inode->i_mutex); | 6502 | mutex_lock(&inode->i_mutex); |
6501 | first_index = start >> PAGE_CACHE_SHIFT; | 6503 | first_index = start >> PAGE_CACHE_SHIFT; |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 6411ed6ca449..8862dda46ff6 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -1920,6 +1920,8 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree, | |||
1920 | nr = bio_get_nr_vecs(bdev); | 1920 | nr = bio_get_nr_vecs(bdev); |
1921 | 1921 | ||
1922 | bio = btrfs_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH); | 1922 | bio = btrfs_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH); |
1923 | if (!bio) | ||
1924 | return -ENOMEM; | ||
1923 | 1925 | ||
1924 | bio_add_page(bio, page, page_size, offset); | 1926 | bio_add_page(bio, page, page_size, offset); |
1925 | bio->bi_end_io = end_io_func; | 1927 | bio->bi_end_io = end_io_func; |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 42dfc3077040..6d66e5caff97 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -2751,7 +2751,13 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2751 | log = root->log_root; | 2751 | log = root->log_root; |
2752 | 2752 | ||
2753 | path = btrfs_alloc_path(); | 2753 | path = btrfs_alloc_path(); |
2754 | if (!path) | ||
2755 | return -ENOMEM; | ||
2754 | dst_path = btrfs_alloc_path(); | 2756 | dst_path = btrfs_alloc_path(); |
2757 | if (!dst_path) { | ||
2758 | btrfs_free_path(path); | ||
2759 | return -ENOMEM; | ||
2760 | } | ||
2755 | 2761 | ||
2756 | min_key.objectid = inode->i_ino; | 2762 | min_key.objectid = inode->i_ino; |
2757 | min_key.type = BTRFS_INODE_ITEM_KEY; | 2763 | min_key.type = BTRFS_INODE_ITEM_KEY; |