Skip to content

Commit a23ba98

Browse files
rleongregkh
authored andcommitted
RDMA/core: Always release restrack object
[ Upstream commit 3d82875 ] Change location of rdma_restrack_del() to fix the bug where task_struct was acquired but not released, causing to resource leak. ucma_create_id() { ucma_alloc_ctx(); rdma_create_user_id() { rdma_restrack_new(); rdma_restrack_set_name() { rdma_restrack_attach_task.part.0(); <--- task_struct was gotten } } ucma_destroy_private_ctx() { ucma_put_ctx(); rdma_destroy_id() { _destroy_id() <--- id_priv was freed } } } Fixes: 889d916 ("RDMA/core: Don't access cm_id after its destruction") Link: https://lore.kernel.org/r/073ec27acb943ca8b6961663c47c5abe78a5c8cc.1624948948.git.leonro@nvidia.com Reported-by: Pavel Skripkin <paskripkin@gmail.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a938d4e commit a23ba98

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • drivers/infiniband/core

‎drivers/infiniband/core/cma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,7 @@ static void _destroy_id(struct rdma_id_private *id_priv,
18561856
{
18571857
cma_cancel_operation(id_priv, state);
18581858

1859+
rdma_restrack_del(&id_priv->res);
18591860
if (id_priv->cma_dev) {
18601861
if (rdma_cap_ib_cm(id_priv->id.device, 1)) {
18611862
if (id_priv->cm_id.ib)
@@ -1865,7 +1866,6 @@ static void _destroy_id(struct rdma_id_private *id_priv,
18651866
iw_destroy_cm_id(id_priv->cm_id.iw);
18661867
}
18671868
cma_leave_mc_groups(id_priv);
1868-
rdma_restrack_del(&id_priv->res);
18691869
cma_release_dev(id_priv);
18701870
}
18711871

0 commit comments

Comments
 (0)