diff options
author | Yongzhi Liu <lyz_cs@pku.edu.cn> | 2022-03-11 20:06:01 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2022-03-15 02:41:10 +0300 |
commit | 087f9c3f2309ed183f7e4b85ae57121d8663224d (patch) | |
tree | 9d3158c194380eb3f01cb28b81670bf6c7bcf01b /drivers/infiniband | |
parent | 7922d3de4d270a9aedb71212fc0d5ae697ced516 (diff) | |
download | linux-087f9c3f2309ed183f7e4b85ae57121d8663224d.tar.xz |
RDMA/mlx5: Fix memory leak in error flow for subscribe event routine
In case the second xa_insert() fails, the obj_event is not released. Fix
the error unwind flow to free that memory to avoid a memory leak.
Fixes: 759738537142 ("IB/mlx5: Enable subscription for device events over DEVX")
Link: https://lore.kernel.org/r/1647018361-18266-1-git-send-email-lyz_cs@pku.edu.cn
Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/mlx5/devx.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c index 08b7f6bc56c3..15c0884d1f49 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); } |