diff mbox series

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

Message ID 20190401134036.8377-1-shhuiw@foxmail.com (mailing list archive)
State New, archived
Headers show
Series block: use blk_free_flush_queue() to free hctx->fq in blk_mq_init_hctx | expand

Commit Message

Shenghui Wang April 1, 2019, 1:40 p.m. UTC
kfree() can leak the hctx->fq->flush_rq field.

Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ming Lei April 2, 2019, 7:59 a.m. UTC | #1
On Mon, Apr 1, 2019 at 9:41 PM Shenghui Wang <shhuiw@foxmail.com> wrote:
>
> kfree() can leak the hctx->fq->flush_rq field.
>
> Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
> ---
>  block/blk-mq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 3ff3d7b49969..f3b0d33bdf88 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -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);

Reviewed-by: Ming Lei <ming.lei@redhat.com>

Thanks,
Ming Lei
Jens Axboe April 2, 2019, 2:20 p.m. UTC | #2
On 4/1/19 7:40 AM, Shenghui Wang wrote:
> kfree() can leak the hctx->fq->flush_rq field.

Applied, thanks.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 3ff3d7b49969..f3b0d33bdf88 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -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);