Commit 5df67083 authored by Tsutomu Itoh's avatar Tsutomu Itoh Committed by Chris Mason

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: default avatarTsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent c87fb6fd
...@@ -6496,6 +6496,8 @@ static noinline int relocate_inode_pages(struct inode *inode, u64 start, ...@@ -6496,6 +6496,8 @@ static noinline int relocate_inode_pages(struct inode *inode, u64 start,
int ret = 0; int ret = 0;
ra = kzalloc(sizeof(*ra), GFP_NOFS); ra = kzalloc(sizeof(*ra), GFP_NOFS);
if (!ra)
return -ENOMEM;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
first_index = start >> PAGE_CACHE_SHIFT; first_index = start >> PAGE_CACHE_SHIFT;
......
...@@ -1920,6 +1920,8 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree, ...@@ -1920,6 +1920,8 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
nr = bio_get_nr_vecs(bdev); nr = bio_get_nr_vecs(bdev);
bio = btrfs_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH); bio = btrfs_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH);
if (!bio)
return -ENOMEM;
bio_add_page(bio, page, page_size, offset); bio_add_page(bio, page, page_size, offset);
bio->bi_end_io = end_io_func; bio->bi_end_io = end_io_func;
......
...@@ -2751,7 +2751,13 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, ...@@ -2751,7 +2751,13 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
log = root->log_root; log = root->log_root;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
dst_path = btrfs_alloc_path(); dst_path = btrfs_alloc_path();
if (!dst_path) {
btrfs_free_path(path);
return -ENOMEM;
}
min_key.objectid = inode->i_ino; min_key.objectid = inode->i_ino;
min_key.type = BTRFS_INODE_ITEM_KEY; min_key.type = BTRFS_INODE_ITEM_KEY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment