Skip to content

Commit 613b148

Browse files
committed
block: handle bio_split_to_limits() NULL return
This can't happen right now, but in preparation for allowing bio_split_to_limits() returning NULL if it ended the bio, check for it in all the callers. Signed-off-by: Jens Axboe <[email protected]>
1 parent 1551ed5 commit 613b148

File tree

8 files changed

+19
-2
lines changed

8 files changed

+19
-2
lines changed

block/blk-merge.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,13 @@ struct bio *__bio_split_to_limits(struct bio *bio,
358358
default:
359359
split = bio_split_rw(bio, lim, nr_segs, bs,
360360
get_max_io_size(bio, lim) << SECTOR_SHIFT);
361+
if (IS_ERR(split))
362+
return NULL;
361363
break;
362364
}
363365

364366
if (split) {
365-
/* there isn't chance to merge the splitted bio */
367+
/* there isn't chance to merge the split bio */
366368
split->bi_opf |= REQ_NOMERGE;
367369

368370
blkcg_bio_issue_init(split);

block/blk-mq.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2951,8 +2951,11 @@ void blk_mq_submit_bio(struct bio *bio)
29512951
blk_status_t ret;
29522952

29532953
bio = blk_queue_bounce(bio, q);
2954-
if (bio_may_exceed_limits(bio, &q->limits))
2954+
if (bio_may_exceed_limits(bio, &q->limits)) {
29552955
bio = __bio_split_to_limits(bio, &q->limits, &nr_segs);
2956+
if (!bio)
2957+
return;
2958+
}
29562959

29572960
if (!bio_integrity_prep(bio))
29582961
return;

drivers/block/drbd/drbd_req.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,8 @@ void drbd_submit_bio(struct bio *bio)
16071607
struct drbd_device *device = bio->bi_bdev->bd_disk->private_data;
16081608

16091609
bio = bio_split_to_limits(bio);
1610+
if (!bio)
1611+
return;
16101612

16111613
/*
16121614
* what we "blindly" assume:

drivers/block/ps3vram.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ static void ps3vram_submit_bio(struct bio *bio)
587587
dev_dbg(&dev->core, "%s\n", __func__);
588588

589589
bio = bio_split_to_limits(bio);
590+
if (!bio)
591+
return;
590592

591593
spin_lock_irq(&priv->lock);
592594
busy = !bio_list_empty(&priv->list);

drivers/md/dm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,8 @@ static void dm_split_and_process_bio(struct mapped_device *md,
17421742
* otherwise associated queue_limits won't be imposed.
17431743
*/
17441744
bio = bio_split_to_limits(bio);
1745+
if (!bio)
1746+
return;
17451747
}
17461748

17471749
init_clone_info(&ci, md, map, bio, is_abnormal);

drivers/md/md.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ static void md_submit_bio(struct bio *bio)
455455
}
456456

457457
bio = bio_split_to_limits(bio);
458+
if (!bio)
459+
return;
458460

459461
if (mddev->ro == MD_RDONLY && unlikely(rw == WRITE)) {
460462
if (bio_sectors(bio) != 0)

drivers/nvme/host/multipath.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ static void nvme_ns_head_submit_bio(struct bio *bio)
376376
* pool from the original queue to allocate the bvecs from.
377377
*/
378378
bio = bio_split_to_limits(bio);
379+
if (!bio)
380+
return;
379381

380382
srcu_idx = srcu_read_lock(&head->srcu);
381383
ns = nvme_find_path(head);

drivers/s390/block/dcssblk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,8 @@ dcssblk_submit_bio(struct bio *bio)
865865
unsigned long bytes_done;
866866

867867
bio = bio_split_to_limits(bio);
868+
if (!bio)
869+
return;
868870

869871
bytes_done = 0;
870872
dev_info = bio->bi_bdev->bd_disk->private_data;

0 commit comments

Comments
 (0)