aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>2011-03-01 01:48:31 -0500
committerroot <Chris Mason chris.mason@oracle.com>2011-03-28 05:37:54 -0400
commitc2db1073fdf9757e6fd8b4a59d15b6ecc7a2af8a (patch)
tree024264b2d27f75b967efbde01060ebb8626fa39d /fs
parentc59021f846881a957ac5afe456d0f59d6a517b61 (diff)
Btrfs: check return value of btrfs_alloc_path()
Adding the check on the return value of btrfs_alloc_path() to several places. And, some of callers are modified by this change. Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/compression.c11
-rw-r--r--fs/btrfs/dir-item.c10
-rw-r--r--fs/btrfs/file-item.c2
-rw-r--r--fs/btrfs/inode.c18
4 files changed, 27 insertions, 14 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 992a4b92083e..41d1d7c70e29 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -663,8 +663,9 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
663 atomic_inc(&cb->pending_bios); 663 atomic_inc(&cb->pending_bios);
664 664
665 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) { 665 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
666 btrfs_lookup_bio_sums(root, inode, comp_bio, 666 ret = btrfs_lookup_bio_sums(root, inode,
667 sums); 667 comp_bio, sums);
668 BUG_ON(ret);
668 } 669 }
669 sums += (comp_bio->bi_size + root->sectorsize - 1) / 670 sums += (comp_bio->bi_size + root->sectorsize - 1) /
670 root->sectorsize; 671 root->sectorsize;
@@ -689,8 +690,10 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
689 ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0); 690 ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0);
690 BUG_ON(ret); 691 BUG_ON(ret);
691 692
692 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) 693 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
693 btrfs_lookup_bio_sums(root, inode, comp_bio, sums); 694 ret = btrfs_lookup_bio_sums(root, inode, comp_bio, sums);
695 BUG_ON(ret);
696 }
694 697
695 ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0); 698 ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0);
696 BUG_ON(ret); 699 BUG_ON(ret);
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index 02c97ad61b6d..c62f02f6ae69 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -151,7 +151,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
151 ret = PTR_ERR(dir_item); 151 ret = PTR_ERR(dir_item);
152 if (ret == -EEXIST) 152 if (ret == -EEXIST)
153 goto second_insert; 153 goto second_insert;
154 goto out; 154 goto out_free;
155 } 155 }
156 156
157 leaf = path->nodes[0]; 157 leaf = path->nodes[0];
@@ -170,7 +170,7 @@ second_insert:
170 /* FIXME, use some real flag for selecting the extra index */ 170 /* FIXME, use some real flag for selecting the extra index */
171 if (root == root->fs_info->tree_root) { 171 if (root == root->fs_info->tree_root) {
172 ret = 0; 172 ret = 0;
173 goto out; 173 goto out_free;
174 } 174 }
175 btrfs_release_path(root, path); 175 btrfs_release_path(root, path);
176 176
@@ -180,7 +180,7 @@ second_insert:
180 name, name_len); 180 name, name_len);
181 if (IS_ERR(dir_item)) { 181 if (IS_ERR(dir_item)) {
182 ret2 = PTR_ERR(dir_item); 182 ret2 = PTR_ERR(dir_item);
183 goto out; 183 goto out_free;
184 } 184 }
185 leaf = path->nodes[0]; 185 leaf = path->nodes[0];
186 btrfs_cpu_key_to_disk(&disk_key, location); 186 btrfs_cpu_key_to_disk(&disk_key, location);
@@ -192,7 +192,9 @@ second_insert:
192 name_ptr = (unsigned long)(dir_item + 1); 192 name_ptr = (unsigned long)(dir_item + 1);
193 write_extent_buffer(leaf, name, name_ptr, name_len); 193 write_extent_buffer(leaf, name, name_ptr, name_len);
194 btrfs_mark_buffer_dirty(leaf); 194 btrfs_mark_buffer_dirty(leaf);
195out: 195
196out_free:
197
196 btrfs_free_path(path); 198 btrfs_free_path(path);
197 if (ret) 199 if (ret)
198 return ret; 200 return ret;
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index a2134195a85e..a6a9d4e8b491 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -170,6 +170,8 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root,
170 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; 170 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
171 171
172 path = btrfs_alloc_path(); 172 path = btrfs_alloc_path();
173 if (!path)
174 return -ENOMEM;
173 if (bio->bi_size > PAGE_CACHE_SIZE * 8) 175 if (bio->bi_size > PAGE_CACHE_SIZE * 8)
174 path->reada = 2; 176 path->reada = 2;
175 177
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f739b256967e..04e9fffee8cc 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1467,8 +1467,11 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
1467 if (bio_flags & EXTENT_BIO_COMPRESSED) { 1467 if (bio_flags & EXTENT_BIO_COMPRESSED) {
1468 return btrfs_submit_compressed_read(inode, bio, 1468 return btrfs_submit_compressed_read(inode, bio,
1469 mirror_num, bio_flags); 1469 mirror_num, bio_flags);
1470 } else if (!skip_sum) 1470 } else if (!skip_sum) {
1471 btrfs_lookup_bio_sums(root, inode, bio, NULL); 1471 ret = btrfs_lookup_bio_sums(root, inode, bio, NULL);
1472 if (ret)
1473 return ret;
1474 }
1472 goto mapit; 1475 goto mapit;
1473 } else if (!skip_sum) { 1476 } else if (!skip_sum) {
1474 /* csum items have already been cloned */ 1477 /* csum items have already been cloned */
@@ -1903,10 +1906,10 @@ static int btrfs_io_failed_hook(struct bio *failed_bio,
1903 else 1906 else
1904 rw = READ; 1907 rw = READ;
1905 1908
1906 BTRFS_I(inode)->io_tree.ops->submit_bio_hook(inode, rw, bio, 1909 ret = BTRFS_I(inode)->io_tree.ops->submit_bio_hook(inode, rw, bio,
1907 failrec->last_mirror, 1910 failrec->last_mirror,
1908 failrec->bio_flags, 0); 1911 failrec->bio_flags, 0);
1909 return 0; 1912 return ret;
1910} 1913}
1911 1914
1912/* 1915/*
@@ -5943,9 +5946,12 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
5943 __btrfs_submit_bio_start_direct_io, 5946 __btrfs_submit_bio_start_direct_io,
5944 __btrfs_submit_bio_done); 5947 __btrfs_submit_bio_done);
5945 goto err; 5948 goto err;
5946 } else if (!skip_sum) 5949 } else if (!skip_sum) {
5947 btrfs_lookup_bio_sums_dio(root, inode, bio, 5950 ret = btrfs_lookup_bio_sums_dio(root, inode, bio,
5948 file_offset, csums); 5951 file_offset, csums);
5952 if (ret)
5953 goto err;
5954 }
5949 5955
5950 ret = btrfs_map_bio(root, rw, bio, 0, 1); 5956 ret = btrfs_map_bio(root, rw, bio, 0, 1);
5951err: 5957err: