[PATCHv3 1/7] blk-mq: introduce blk_map_iter
Keith Busch
kbusch at kernel.org
Wed Jul 30 08:18:20 PDT 2025
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.
More information about the Linux-nvme
mailing list