From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
Yishai Hadas <yishaih@nvidia.com>,
Chiara Meiohas <cmeiohas@nvidia.com>,
Michal Kalderon <mkalderon@marvell.com>,
Selvin Xavier <selvin.xavier@broadcom.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Maher Sanalla <msanalla@nvidia.com>
Subject: [PATCH rdma-next 3/6] RDMA/mlx5: Fix ucaps init error flow
Date: Sun, 4 Jan 2026 15:51:35 +0200 [thread overview]
Message-ID: <20260104-ib-core-misc-v1-3-00367f77f3a8@nvidia.com> (raw)
In-Reply-To: <20260104-ib-core-misc-v1-0-00367f77f3a8@nvidia.com>
From: Maher Sanalla <msanalla@nvidia.com>
In mlx5_ib_stage_caps_init(), if mlx5_ib_init_ucaps() fails after
mlx5_ib_init_var_table() succeeds, the VAR bitmap is leaked since
the function returns without cleanup.
Thus, cleanup the var table bitmap in case of error of initializing
ucaps before exiting, preventing the leak above.
Fixes: cf7174e8982f ("RDMA/mlx5: Create UCAP char devices for supported device capabilities")
Signed-off-by: Maher Sanalla <msanalla@nvidia.com>
Reviewed-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/infiniband/hw/mlx5/main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 40284bbb45d6..8d515d266125 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -4466,12 +4466,16 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
MLX5_HCA_CAP_2_GENERAL_OBJECT_TYPES_RDMA_CTRL) {
err = mlx5_ib_init_ucaps(dev);
if (err)
- return err;
+ goto err_ucaps;
}
dev->ib_dev.use_cq_dim = true;
return 0;
+
+err_ucaps:
+ bitmap_free(dev->var_table.bitmap);
+ return err;
}
static const struct ib_device_ops mlx5_ib_dev_port_ops = {
--
2.52.0
next prev parent reply other threads:[~2026-01-04 13:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-04 13:51 [PATCH rdma-next 0/6] Batch of unrelated cleanups in IB Leon Romanovsky
2026-01-04 13:51 ` [PATCH rdma-next 1/6] RDMA/umem: Remove redundant DMABUF ops check Leon Romanovsky
2026-01-05 3:29 ` Kalesh Anakkur Purayil
2026-01-04 13:51 ` [PATCH rdma-next 2/6] RDMA/core: Avoid exporting module local functions and remove not-used ones Leon Romanovsky
2026-01-05 3:45 ` Kalesh Anakkur Purayil
2026-01-05 5:01 ` Zhu Yanjun
2026-01-04 13:51 ` Leon Romanovsky [this message]
2026-01-05 3:37 ` [PATCH rdma-next 3/6] RDMA/mlx5: Fix ucaps init error flow Kalesh Anakkur Purayil
2026-01-04 13:51 ` [PATCH rdma-next 4/6] RDMA/mlx5: Avoid direct access to DMA device pointer Leon Romanovsky
2026-01-05 3:45 ` Kalesh Anakkur Purayil
2026-01-04 13:51 ` [PATCH rdma-next 5/6] RDMA/qedr: Remove unused defines Leon Romanovsky
2026-01-05 3:34 ` Kalesh Anakkur Purayil
2026-01-04 13:51 ` [PATCH rdma-next 6/6] RDMA/ocrdma: Remove unused OCRDMA_UVERBS definition Leon Romanovsky
2026-01-05 3:41 ` Kalesh Anakkur Purayil
2026-01-05 9:07 ` [PATCH rdma-next 0/6] Batch of unrelated cleanups in IB Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260104-ib-core-misc-v1-3-00367f77f3a8@nvidia.com \
--to=leon@kernel.org \
--cc=cmeiohas@nvidia.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mkalderon@marvell.com \
--cc=msanalla@nvidia.com \
--cc=selvin.xavier@broadcom.com \
--cc=yishaih@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®