Skip to content

Commit

Permalink
ext4: add check to io_submit_init_bio
Browse files Browse the repository at this point in the history
The bio_alloc() function can return NULL if the memory allocation
fails.  So we need to check for this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Theodore Ts'o committed Jun 6, 2013
1 parent 5dc23bd commit a1d8d9a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/ext4/page-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ static int io_submit_init_bio(struct ext4_io_submit *io,
struct bio *bio;

bio = bio_alloc(GFP_NOIO, min(nvecs, BIO_MAX_PAGES));
if (!bio)
return -ENOMEM;
bio->bi_sector = bh->b_blocknr * (bh->b_size >> 9);
bio->bi_bdev = bh->b_bdev;
bio->bi_end_io = ext4_end_bio;
Expand Down

0 comments on commit a1d8d9a

Please sign in to comment.