Skip to content

Commit

Permalink
block: handle bio_split_to_limits() NULL return
Browse files Browse the repository at this point in the history
commit 613b148 upstream.

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 <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
axboe authored and gregkh committed Jan 18, 2023
1 parent ba86db0 commit 7ec9a45
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion block/blk-merge.c
Expand Up @@ -348,11 +348,13 @@ void __blk_queue_split(struct bio **bio, unsigned int *nr_segs)
break;
}
split = blk_bio_segment_split(q, *bio, &q->bio_split, nr_segs);
if (IS_ERR(split))
*bio = split = NULL;
break;
}

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

bio_chain(split, *bio);
Expand Down
2 changes: 2 additions & 0 deletions block/blk-mq.c
Expand Up @@ -2193,6 +2193,8 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)

blk_queue_bounce(q, &bio);
__blk_queue_split(&bio, &nr_segs);
if (!bio)
goto queue_exit;

if (!bio_integrity_prep(bio))
goto queue_exit;
Expand Down
2 changes: 2 additions & 0 deletions drivers/block/drbd/drbd_req.c
Expand Up @@ -1602,6 +1602,8 @@ blk_qc_t drbd_submit_bio(struct bio *bio)
struct drbd_device *device = bio->bi_bdev->bd_disk->private_data;

blk_queue_split(&bio);
if (!bio)
return BLK_QC_T_NONE;

/*
* what we "blindly" assume:
Expand Down
2 changes: 2 additions & 0 deletions drivers/block/pktcdvd.c
Expand Up @@ -2407,6 +2407,8 @@ static blk_qc_t pkt_submit_bio(struct bio *bio)
struct bio *split;

blk_queue_split(&bio);
if (!bio)
return BLK_QC_T_NONE;

pd = bio->bi_bdev->bd_disk->queue->queuedata;
if (!pd) {
Expand Down
2 changes: 2 additions & 0 deletions drivers/block/ps3vram.c
Expand Up @@ -587,6 +587,8 @@ static blk_qc_t ps3vram_submit_bio(struct bio *bio)
dev_dbg(&dev->core, "%s\n", __func__);

blk_queue_split(&bio);
if (!bio)
return BLK_QC_T_NONE;

spin_lock_irq(&priv->lock);
busy = !bio_list_empty(&priv->list);
Expand Down
2 changes: 2 additions & 0 deletions drivers/block/rsxx/dev.c
Expand Up @@ -127,6 +127,8 @@ static blk_qc_t rsxx_submit_bio(struct bio *bio)
blk_status_t st = BLK_STS_IOERR;

blk_queue_split(&bio);
if (!bio)
return BLK_QC_T_NONE;

might_sleep();

Expand Down
2 changes: 2 additions & 0 deletions drivers/md/md.c
Expand Up @@ -458,6 +458,8 @@ static blk_qc_t md_submit_bio(struct bio *bio)
}

blk_queue_split(&bio);
if (!bio)
return BLK_QC_T_NONE;

if (mddev->ro == 1 && unlikely(rw == WRITE)) {
if (bio_sectors(bio) != 0)
Expand Down
2 changes: 2 additions & 0 deletions drivers/nvme/host/multipath.c
Expand Up @@ -329,6 +329,8 @@ static blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
* pool from the original queue to allocate the bvecs from.
*/
blk_queue_split(&bio);
if (!bio)
return BLK_QC_T_NONE;

srcu_idx = srcu_read_lock(&head->srcu);
ns = nvme_find_path(head);
Expand Down
2 changes: 2 additions & 0 deletions drivers/s390/block/dcssblk.c
Expand Up @@ -866,6 +866,8 @@ dcssblk_submit_bio(struct bio *bio)
unsigned long bytes_done;

blk_queue_split(&bio);
if (!bio)
return BLK_QC_T_NONE;

bytes_done = 0;
dev_info = bio->bi_bdev->bd_disk->private_data;
Expand Down

0 comments on commit 7ec9a45

Please sign in to comment.