diff options
author | Tsutomu Itoh <t-itoh@jp.fujitsu.com> | 2012-04-12 16:03:56 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2012-04-12 16:03:56 -0400 |
commit | e627ee7bcd42b4e3a03ca01a8e46dcb4033c5ae0 (patch) | |
tree | a6f8060dd57184e79b5c46404c941f999137030d /fs/btrfs/scrub.c | |
parent | c6664b42c4e567792abdb17c958fb01c5bcfcb3a (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/scrub.c')
-rw-r--r-- | fs/btrfs/scrub.c | 4 |
1 files changed, 4 insertions, 0 deletions
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; |