[PATCH 3/5] bio: Protect submit_bio from bdevless bio-s
From: Dmitry Monakhov
Date: Thu Apr 06 2017 - 08:03:41 EST
Idially this type of check should be handled at generic_make_request_checks
, but it is too late for bdevless bios, bad pointer was already
dereferenced at that point.
Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
---
block/blk-core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block/blk-core.c b/block/blk-core.c
index 275c1e4..e583ded 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2065,6 +2065,11 @@ EXPORT_SYMBOL(generic_make_request);
*/
blk_qc_t submit_bio(struct bio *bio)
{
+ if (WARN_ON_ONCE(!bio->bi_bdev)) {
+ bio_io_error(bio);
+ return BLK_QC_T_NONE;
+ }
+
/*
* If it's a regular read/write or a barrier with data attached,
* go through the normal accounting stuff before submission.
--
2.9.3