lkml.org 
[lkml]   [2022]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] RDMA/mlx5: Fix memory leak
    Date
    [why]
    xa_insert is failed, so caller of subscribe_event_xa_alloc
    cannot call other function to free obj_event. Therefore,
    Resource release is needed on the error handling path to
    prevent memory leak.

    [how]
    Fix this by adding kfree on the error handling path.

    Fixes: 7597385 ("IB/mlx5: Enable subscription for device events over DEVX")

    Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
    ---
    drivers/infiniband/hw/mlx5/devx.c | 4 +++-
    1 file changed, 3 insertions(+), 1 deletion(-)

    diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c
    index 08b7f6b..15c0884 100644
    --- a/drivers/infiniband/hw/mlx5/devx.c
    +++ b/drivers/infiniband/hw/mlx5/devx.c
    @@ -1886,8 +1886,10 @@ subscribe_event_xa_alloc(struct mlx5_devx_event_table *devx_event_table,
    key_level2,
    obj_event,
    GFP_KERNEL);
    - if (err)
    + if (err) {
    + kfree(obj_event);
    return err;
    + }
    INIT_LIST_HEAD(&obj_event->obj_sub_list);
    }

    --
    2.7.4
    \
     
     \ /
      Last update: 2022-03-11 18:07    [W:5.716 / U:0.444 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site