public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: blk-flush: Check return value of bio_alloc()
@ 2015-06-21  8:39 Axel Lin
  0 siblings, 0 replies; only message in thread
From: Axel Lin @ 2015-06-21  8:39 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Ming Lei, Christoph Hellwig, linux-kernel@vger.kernel.org

bio_alloc() can return NULL, so add NULL test to prevent NULL pointer
dereference.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 block/blk-flush.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index 20badd7..4706641 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -470,6 +470,9 @@ 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);
-- 
2.1.0



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-06-21  8:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-21  8:39 [PATCH] block: blk-flush: Check return value of bio_alloc() Axel Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox