block: handle bio_split_to_limits() NULL return
authorJens Axboe <axboe@kernel.dk>
Wed, 4 Jan 2023 15:51:19 +0000 (08:51 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:48:58 +0000 (11:48 +0100)
commit 613b14884b8595e20b9fac4126bf627313827fbe 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>
block/blk-merge.c
block/blk-mq.c
drivers/block/drbd/drbd_req.c
drivers/block/pktcdvd.c
drivers/block/ps3vram.c
drivers/block/rsxx/dev.c
drivers/md/md.c
drivers/nvme/host/multipath.c
drivers/s390/block/dcssblk.c

index bb26db93ad1de68a78c472e8727cd9f4b292dc3e..d1435b6572977fa0466ec501ebbe0231cb68b90c 100644 (file)
@@ -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);
index 1a28ba9017edb260ed5768bdac330d320b074ec1..9f53b4caf977264e15f5543dcc248cdba6e2875d 100644 (file)
@@ -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;
index 47e0d105b462e5bb3e09e2b94d4a2f9a2801218f..4281dc847bc225c5fc582013d0668f85a5e22d1d 100644 (file)
@@ -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:
index 0f26b2510a756d9093b2c884d5f4b669f61af8e1..ca2ab977ef8efe5dd1b8b8e6561fb4aa60e8b05b 100644 (file)
@@ -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) {
index c7b19e128b03c79c010d416878b0a2cfac985454..c79aa4d8ccf73645e9229bcf0fb47b5d12b62827 100644 (file)
@@ -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);
index 1cc40b0ea761906906258e10eea17519285ad33a..6b253d99bc48d2c83d868bbf1768d43f8f3becd7 100644 (file)
@@ -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();
 
index 59ab99844df8eb795c99269df614ef1e78918db9..9e54b865f30da2ae2eb110ecf1d16e523425cd12 100644 (file)
@@ -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)
index fe199d568a4a86f48228a1160ee82f2e391054f0..8d97b942de01fff9afa3ca8fec256fa5c4fb37bc 100644 (file)
@@ -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);
index 5be3d1c39a78eeb1c5991fd2030453c455600cac..54176c073547b26bf8a0d9531989373d9ecd6d17 100644 (file)
@@ -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;