Skip to contentSkip to conversation

block: blk-flush: Check return value of bio_alloc()

PATCH New Axel Lin 1 participant 1 message Jun 21, 2015 Block layer

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 block: blk-flush: Check return value of bio_alloc()

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

---
 block/blk-flush.c | 3 +++
 1 file changed, 3 insertions(+)
block/blk-flush.c +3 -0
index 20badd7..4706641 100644
@@ -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);
Signature · 7 lines
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/