Skip to contentSkip to conversation

block: use blk_free_flush_queue() to free hctx->fq in blk_mq_init_hctx

PATCH Applied Shenghui Wang 3 participants 3 messages Apr 1, 2019 – Apr 2, 2019 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: use blk_free_flush_queue() to free hctx->fq in blk_mq_init_hctx

kfree() can leak the hctx->fq->flush_rq field.

---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq.c +1 -1
index 3ff3d7b49969..f3b0d33bdf88 100644
@@ -2332,7 +2332,7 @@ static int blk_mq_init_hctx(struct request_queue *q,
 	return 0;
 
  free_fq:
-	kfree(hctx->fq);
+	blk_free_flush_queue(hctx->fq);
  exit_hctx:
 	if (set->ops->exit_hctx)
 		set->ops->exit_hctx(hctx, hctx_idx);
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Shenghui Wang

kfree() can leak the hctx->fq->flush_rq field.

---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq.c +0 -0
index 3ff3d7b49969..f3b0d33bdf88 100644

block/blk-mq.c static int blk_mq_init_hctx(struct request_queue *q, · line 2338

Quoted 8 lines
block/blk-mq.c +1 -1
@@ -2332,7 +2332,7 @@ static int blk_mq_init_hctx(struct request_queue *q,
        return 0;
 
  free_fq:
-       kfree(hctx->fq);
+       blk_free_flush_queue(hctx->fq);
  exit_hctx:
        if (set->ops->exit_hctx)
                set->ops->exit_hctx(hctx, hctx_idx);

Thanks,
Ming Lei