[PATCH] block: make blkdev_issue_flush check for NULL from bio_alloc

From: Elliott, Robert (Server Storage)
Date: Mon Jul 14 2014 - 10:49:56 EST


bio_alloc can return NULL if gfp_mask does not contain __GPF_WAIT
and it doesn't use a mempool. Since blkdev_issue_flush passes
along gfp_mask, it needs to check if bio_alloc returns NULL.

Signed-off-by: Robert Elliott <elliott@xxxxxx>
---
block/blk-flush.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index 3cb5e9e..2a9fd20 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -457,6 +457,8 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
return -ENXIO;

bio = bio_alloc(gfp_mask, 0);
+ if (!bio)
+ return -ENOMEM;
bio->bi_bdev = bdev;

ret = submit_bio_wait(WRITE_FLUSH, bio);

---
Rob Elliott HP Server Storage