]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
RDMA/mlx5: Fix memory leak in error flow for subscribe event routine
authorYongzhi Liu <lyz_cs@pku.edu.cn>
Fri, 11 Mar 2022 17:06:01 +0000 (09:06 -0800)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:57:55 +0000 (11:57 +0200)
BugLink: https://bugs.launchpad.net/bugs/1969110
[ Upstream commit 087f9c3f2309ed183f7e4b85ae57121d8663224d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 8dd392e352d3269938fea32061a74655a613f929)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/infiniband/hw/mlx5/devx.c

index 7c920be2921d270a667216ee7f33d476714600c7..ba02cd17dbbedfa287c3f638ec6dd35b340b320c 100644 (file)
@@ -1891,8 +1891,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);
        }