aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>2012-04-12 16:03:56 -0400
committerChris Mason <chris.mason@oracle.com>2012-04-12 16:03:56 -0400
commite627ee7bcd42b4e3a03ca01a8e46dcb4033c5ae0 (patch)
treea6f8060dd57184e79b5c46404c941f999137030d /fs/btrfs
parentc6664b42c4e567792abdb17c958fb01c5bcfcb3a (diff)
Btrfs: check return value of bio_alloc() properly
bio_alloc() has the possibility of returning NULL. So, it is necessary to check the return value. Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/compression.c2
-rw-r--r--fs/btrfs/extent_io.c4
-rw-r--r--fs/btrfs/scrub.c4
3 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index d11afa67c7d8..646f5e6f2566 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -405,6 +405,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
405 bio_put(bio); 405 bio_put(bio);
406 406
407 bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS); 407 bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS);
408 BUG_ON(!bio);
408 bio->bi_private = cb; 409 bio->bi_private = cb;
409 bio->bi_end_io = end_compressed_bio_write; 410 bio->bi_end_io = end_compressed_bio_write;
410 bio_add_page(bio, page, PAGE_CACHE_SIZE, 0); 411 bio_add_page(bio, page, PAGE_CACHE_SIZE, 0);
@@ -687,6 +688,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
687 688
688 comp_bio = compressed_bio_alloc(bdev, cur_disk_byte, 689 comp_bio = compressed_bio_alloc(bdev, cur_disk_byte,
689 GFP_NOFS); 690 GFP_NOFS);
691 BUG_ON(!comp_bio);
690 comp_bio->bi_private = cb; 692 comp_bio->bi_private = cb;
691 comp_bio->bi_end_io = end_compressed_bio_read; 693 comp_bio->bi_end_io = end_compressed_bio_read;
692 694
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 59ec105444fe..4789770f8eaf 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2180,6 +2180,10 @@ static int bio_readpage_error(struct bio *failed_bio, struct page *page,
2180 } 2180 }
2181 2181
2182 bio = bio_alloc(GFP_NOFS, 1); 2182 bio = bio_alloc(GFP_NOFS, 1);
2183 if (!bio) {
2184 free_io_failure(inode, failrec, 0);
2185 return -EIO;
2186 }
2183 bio->bi_private = state; 2187 bio->bi_private = state;
2184 bio->bi_end_io = failed_bio->bi_end_io; 2188 bio->bi_end_io = failed_bio->bi_end_io;
2185 bio->bi_sector = failrec->logical >> 9; 2189 bio->bi_sector = failrec->logical >> 9;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index c9a2c1aef4bd..60f0e28db31e 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1044,6 +1044,8 @@ static int scrub_recheck_block(struct btrfs_fs_info *fs_info,
1044 1044
1045 BUG_ON(!page->page); 1045 BUG_ON(!page->page);
1046 bio = bio_alloc(GFP_NOFS, 1); 1046 bio = bio_alloc(GFP_NOFS, 1);
1047 if (!bio)
1048 return -EIO;
1047 bio->bi_bdev = page->bdev; 1049 bio->bi_bdev = page->bdev;
1048 bio->bi_sector = page->physical >> 9; 1050 bio->bi_sector = page->physical >> 9;
1049 bio->bi_end_io = scrub_complete_bio_end_io; 1051 bio->bi_end_io = scrub_complete_bio_end_io;
@@ -1172,6 +1174,8 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad,
1172 DECLARE_COMPLETION_ONSTACK(complete); 1174 DECLARE_COMPLETION_ONSTACK(complete);
1173 1175
1174 bio = bio_alloc(GFP_NOFS, 1); 1176 bio = bio_alloc(GFP_NOFS, 1);
1177 if (!bio)
1178 return -EIO;
1175 bio->bi_bdev = page_bad->bdev; 1179 bio->bi_bdev = page_bad->bdev;
1176 bio->bi_sector = page_bad->physical >> 9; 1180 bio->bi_sector = page_bad->physical >> 9;
1177 bio->bi_end_io = scrub_complete_bio_end_io; 1181 bio->bi_end_io = scrub_complete_bio_end_io;