Linux block layer
 help / color / mirror / Atom feed
From: Kanchan Joshi <joshi.k@samsung.com>
To: Keith Busch <kbusch@kernel.org>
Cc: Keith Busch <kbusch@meta.com>,
	linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
	hch@lst.de, axboe@kernel.dk, leonro@nvidia.com
Subject: Re: [PATCHv3 1/7] blk-mq: introduce blk_map_iter
Date: Thu, 31 Jul 2025 10:35:23 +0530	[thread overview]
Message-ID: <c2774764-651f-49d3-8e7e-2609a8dc035e@samsung.com> (raw)
In-Reply-To: <aIo3vLnxQFWCD_pv@kbusch-mbp>

On 7/30/2025 8:48 PM, Keith Busch wrote:
> On Wed, Jul 30, 2025 at 01:48:42PM +0530, Kanchan Joshi wrote:
>> On 7/29/2025 8:04 PM, Keith Busch wrote:
>>> @@ -39,12 +33,11 @@ static bool blk_map_iter_next(struct request *req, struct req_iterator *iter,
>>>    	 * one could be merged into it.  This typically happens when moving to
>>>    	 * the next bio, but some callers also don't pack bvecs tight.
>>>    	 */
>>> -	while (!iter->iter.bi_size || !iter->iter.bi_bvec_done) {
>>> +	while (!iter->iter.bi_size ||
>>> +	       (!iter->iter.bi_bvec_done && iter->bio->bi_next)) {
>>>    		struct bio_vec next;
>>>    
>>>    		if (!iter->iter.bi_size) {
>>> -			if (!iter->bio->bi_next)
>>> -				break;
>>>    			iter->bio = iter->bio->bi_next;
>>>    			iter->iter = iter->bio->bi_iter;
>> This can crash here if we come inside the loop because
>> iter->iter.bi_size is 0
>> and if this is the last bio i.e., iter->bio->bi_next is NULL?
> Nah, I changed the while loop condition to ensure bio->bi_next isn't
> NULL if the current bi_size is 0. But I don't recall why I moved the
> condition check to there in the first place either.

Yes, you moved it, but that is not going to guard when 
iter->iter.bi_size is 0.

while (true || immaterial) {
	..
	if (true) {
		iter->bio = NULL;
		iter->iter = iter->bio->bi_iter;  //crash here
	}
}

  reply	other threads:[~2025-07-31  5:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-29 14:34 [PATCHv3 0/7] blk dma iter for integrity metadata Keith Busch
2025-07-29 14:34 ` [PATCHv3 1/7] blk-mq: introduce blk_map_iter Keith Busch
2025-07-30  6:52   ` Kanchan Joshi
2025-07-30  8:18   ` Kanchan Joshi
2025-07-30 15:18     ` Keith Busch
2025-07-31  5:05       ` Kanchan Joshi [this message]
2025-07-29 14:34 ` [PATCHv3 2/7] blk-mq-dma: provide the bio_vec list being iterated Keith Busch
2025-07-29 20:55   ` Keith Busch
2025-07-30 12:15   ` Kanchan Joshi
2025-07-30 14:18     ` Keith Busch
2025-07-29 14:34 ` [PATCHv3 3/7] blk-mq-dma: require unmap caller provide p2p map type Keith Busch
2025-07-29 14:34 ` [PATCHv3 4/7] blk-mq: remove REQ_P2PDMA flag Keith Busch
2025-07-29 14:34 ` [PATCHv3 5/7] blk-mq-dma: move common dma start code to a helper Keith Busch
2025-07-29 14:34 ` [PATCHv3 6/7] blk-mq-dma: add support for mapping integrity metadata Keith Busch
2025-07-29 14:34 ` [PATCHv3 7/7] nvme: convert metadata mapping to dma iter Keith Busch
2025-07-29 18:56   ` Keith Busch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c2774764-651f-49d3-8e7e-2609a8dc035e@samsung.com \
    --to=joshi.k@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=kbusch@meta.com \
    --cc=leonro@nvidia.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox