[PATCHv3 1/7] blk-mq: introduce blk_map_iter
Kanchan Joshi
joshi.k at samsung.com
Wed Jul 30 22:05:23 PDT 2025
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
}
}
More information about the Linux-nvme
mailing list