From patchwork Tue May 30 17:25:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 1787779 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=PK89Sb/p; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVznf0rNjz20Q4 for ; Wed, 31 May 2023 03:25:57 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1q436U-0000RB-A0; Tue, 30 May 2023 17:25:50 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1q436S-0000Qc-0M for kernel-team@lists.ubuntu.com; Tue, 30 May 2023 17:25:48 +0000 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 3B0603F1A6 for ; Tue, 30 May 2023 17:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1685467547; bh=JvMTWHUhPNHIW64FHYOWU/6StkIZLSfUbOUfVU85s3k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PK89Sb/pwV1h2DOiDE60Ft9V+ffvHevcaTGWNXAc722wJWTNvKMRSt+9wbEodNsSk SVhdmmMxD005GEkI16y1lWuLjMwg1aMQVlo7aCuXs0U65+0Uk8nQtpsHNNZLBmxtnb nlgKhT/5sG56fs2p1Q+MmRONNcp/dCwbY1IywDvl3YbKHNwTtNkkxEeVNO8BOYlo98 Ve1JFIaD3kiwBeO7Hev6SEPrQUM8mEsAyZ2Xhhacz25Tob5DSXrBtshtqs32HCvIFM NARQJNr9/B/qxkN+GSIwhQJ8NTrLGW3kp8a/8m1Z/QwqI/d40sqStmExsB50ksJ7eq ByTzDopK2H8Ag== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-96f83b44939so419281866b.1 for ; Tue, 30 May 2023 10:25:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685467545; x=1688059545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JvMTWHUhPNHIW64FHYOWU/6StkIZLSfUbOUfVU85s3k=; b=AJkOm6j2mHA8mzsFK7oXfBEYkioOJGtmifbl1mKsaQHan+SX/PDDaNLASRUGAtHJAg lQh7Ce5waNzcxvZtWu3DMO+afK7h+SvS8i91FS+sgG66LC4zjpIFAbN91WmEJOnQmTnp S59vsI3dXV1MbVGRY289rmJBFMGGg/oyscgKAXuemhJBt8O9O4nrVCiuZD8UfCdzlDRj HZ40sB8SkIM1hMx7yCgs82IlvnWTvu7foAB+wrQgfmP2e10YSfMgBkpGO5TiW0AHhiqe iQoUtJuSBxf5e574oThKGzVZC4nwboSTCGLT+n/u0edN/gkqM2Ce21gNXM88iOrvni7A OZ/Q== X-Gm-Message-State: AC+VfDxq9euaOEk0b35Iiu/NT/WnPA9MOUqLndRymqoGp0r4nY9wySsF hh3GgMXoKkQaYbL+6o+loMxHfognIdaybzSePGQumCf9l1iaYnPbnUoQGKnYC+WT195sNyHnQs9 /LTr6HqVhl1XKeC+HjIN3H6UnlLpOy5t/EQSPM+plJvnAweAD4A== X-Received: by 2002:a17:907:1c9f:b0:8b8:c06e:52d8 with SMTP id nb31-20020a1709071c9f00b008b8c06e52d8mr3720116ejc.36.1685467545091; Tue, 30 May 2023 10:25:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6OIe2gJkXzeBn8k2adZhh8wIe1imFTQJ7c3UGaObp2SZe6/sPHCqMylq0BEnlVZhka33LhIA== X-Received: by 2002:a17:907:1c9f:b0:8b8:c06e:52d8 with SMTP id nb31-20020a1709071c9f00b008b8c06e52d8mr3720102ejc.36.1685467544816; Tue, 30 May 2023 10:25:44 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id h21-20020a1709062dd500b0097404f4a124sm2793727eji.2.2023.05.30.10.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 10:25:44 -0700 (PDT) From: Alexander Mikhalitsyn To: kernel-team@lists.ubuntu.com Subject: [SRU][K:master-next][PATCH 1/1] block: handle bio_split_to_limits() NULL return Date: Tue, 30 May 2023 19:25:17 +0200 Message-Id: <20230530172517.659713-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530172517.659713-1-aleksandr.mikhalitsyn@canonical.com> References: <20230530172517.659713-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kamal.mostafa@canonical.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jens Axboe BugLink: https://bugs.launchpad.net/bugs/2020901 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 Signed-off-by: Greg Kroah-Hartman (backported from commit 613b14884b8595e20b9fac4126bf627313827fbe) Signed-off-by: Alexander Mikhalitsyn --- block/blk-merge.c | 4 +++- block/blk-mq.c | 3 +++ drivers/block/drbd/drbd_req.c | 2 ++ drivers/block/pktcdvd.c | 2 ++ drivers/block/ps3vram.c | 2 ++ drivers/md/dm.c | 2 ++ drivers/md/md.c | 2 ++ drivers/nvme/host/multipath.c | 2 ++ drivers/s390/block/dcssblk.c | 2 ++ 9 files changed, 20 insertions(+), 1 deletion(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 88e39b955bd6..1af8043900f4 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -348,11 +348,13 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio, break; default: 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; blkcg_bio_issue_init(split); diff --git a/block/blk-mq.c b/block/blk-mq.c index 7c7e632871e7..8b22429cf94e 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2818,6 +2818,9 @@ void blk_mq_submit_bio(struct bio *bio) if (blk_may_split(q, bio)) __blk_queue_split(q, &bio, &nr_segs); + if (!bio) + return; + if (!bio_integrity_prep(bio)) return; diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index e60d3c6314c6..f323a4714f6a 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -1609,6 +1609,8 @@ void drbd_submit_bio(struct bio *bio) struct drbd_device *device = bio->bi_bdev->bd_disk->private_data; blk_queue_split(&bio); + if (!bio) + return; /* * what we "blindly" assume: diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 789093375344..1988bb05c0c7 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2400,6 +2400,8 @@ static void pkt_submit_bio(struct bio *bio) struct bio *split; blk_queue_split(&bio); + if (!bio) + return; pkt_dbg(2, pd, "start = %6llx stop = %6llx\n", (unsigned long long)bio->bi_iter.bi_sector, diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 4f90819e245e..2a431178dc7e 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -587,6 +587,8 @@ static void ps3vram_submit_bio(struct bio *bio) dev_dbg(&dev->core, "%s\n", __func__); blk_queue_split(&bio); + if (!bio) + return; spin_lock_irq(&priv->lock); busy = !bio_list_empty(&priv->list); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 5acee96b5a7b..bf904c153d41 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1674,6 +1674,8 @@ static void dm_split_and_process_bio(struct mapped_device *md, * otherwise associated queue_limits won't be imposed. */ blk_queue_split(&bio); + if (!bio) + return; } init_clone_info(&ci, md, map, bio, is_abnormal); diff --git a/drivers/md/md.c b/drivers/md/md.c index 946434ced070..772a89843226 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -465,6 +465,8 @@ static void md_submit_bio(struct bio *bio) } blk_queue_split(&bio); + if (!bio) + return; if (mddev->ro == 1 && unlikely(rw == WRITE)) { if (bio_sectors(bio) != 0) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index d62c4a0f89ab..571c4791faa8 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -351,6 +351,8 @@ static void 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; srcu_idx = srcu_read_lock(&head->srcu); ns = nvme_find_path(head); diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index f4401b2d30e0..18506cc222ba 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -865,6 +865,8 @@ dcssblk_submit_bio(struct bio *bio) unsigned long bytes_done; blk_queue_split(&bio); + if (!bio) + return; bytes_done = 0; dev_info = bio->bi_bdev->bd_disk->private_data;