lkml.org 
[lkml]   [2019]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.1 83/98] blk-mq: Fix memory leak in error handling
    Date
    [ Upstream commit 41de54c64811bf087c8464fdeb43c6ad8be2686b ]

    If blk_mq_init_allocated_queue() fails, make sure to free the poll
    stat callback struct allocated.

    Signed-off-by: Jes Sorensen <jsorensen@fb.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    block/blk-mq.c | 5 ++++-
    1 file changed, 4 insertions(+), 1 deletion(-)

    diff --git a/block/blk-mq.c b/block/blk-mq.c
    index 11efca3534ad..00b826399228 100644
    --- a/block/blk-mq.c
    +++ b/block/blk-mq.c
    @@ -2846,7 +2846,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
    goto err_exit;

    if (blk_mq_alloc_ctxs(q))
    - goto err_exit;
    + goto err_poll;

    /* init q->mq_kobj and sw queues' kobjects */
    blk_mq_sysfs_init(q);
    @@ -2907,6 +2907,9 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
    kfree(q->queue_hw_ctx);
    err_sys_init:
    blk_mq_sysfs_deinit(q);
    +err_poll:
    + blk_stat_free_callback(q->poll_cb);
    + q->poll_cb = NULL;
    err_exit:
    q->mq_ops = NULL;
    return ERR_PTR(-ENOMEM);
    --
    2.20.1


    \
     
     \ /
      Last update: 2019-06-20 20:18    [W:4.059 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site