Skip to content

Commit b93af30

Browse files
John Garryaxboe
authored andcommitted
blk-mq-sched: Fix blk_mq_sched_alloc_tags() error handling
If the blk_mq_sched_alloc_tags() -> blk_mq_alloc_rqs() call fails, then we call blk_mq_sched_free_tags() -> blk_mq_free_rqs(). It is incorrect to do so, as any rqs would have already been freed in the blk_mq_alloc_rqs() call. Fix by calling blk_mq_free_rq_map() only directly. Fixes: 6917ff0 ("blk-mq-sched: refactor scheduler initialization") Signed-off-by: John Garry <[email protected]> Reviewed-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 3ce6e1f commit b93af30

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

block/blk-mq-sched.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,6 @@ void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx,
515515
percpu_ref_put(&q->q_usage_counter);
516516
}
517517

518-
static void blk_mq_sched_free_tags(struct blk_mq_tag_set *set,
519-
struct blk_mq_hw_ctx *hctx,
520-
unsigned int hctx_idx)
521-
{
522-
if (hctx->sched_tags) {
523-
blk_mq_free_rqs(set, hctx->sched_tags, hctx_idx);
524-
blk_mq_free_rq_map(hctx->sched_tags, set->flags);
525-
hctx->sched_tags = NULL;
526-
}
527-
}
528-
529518
static int blk_mq_sched_alloc_tags(struct request_queue *q,
530519
struct blk_mq_hw_ctx *hctx,
531520
unsigned int hctx_idx)
@@ -539,8 +528,10 @@ static int blk_mq_sched_alloc_tags(struct request_queue *q,
539528
return -ENOMEM;
540529

541530
ret = blk_mq_alloc_rqs(set, hctx->sched_tags, hctx_idx, q->nr_requests);
542-
if (ret)
543-
blk_mq_sched_free_tags(set, hctx, hctx_idx);
531+
if (ret) {
532+
blk_mq_free_rq_map(hctx->sched_tags, set->flags);
533+
hctx->sched_tags = NULL;
534+
}
544535

545536
return ret;
546537
}

0 commit comments

Comments
 (0)