* [PATCH] RDMA/ocrdma: kzalloc_objs to kzalloc_flex
@ 2026-03-08 20:14 Rosen Penev
2026-03-10 10:23 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-03-08 20:14 UTC (permalink / raw)
To: linux-rdma
Cc: Selvin Xavier, linux-hardening, gustavoars, Jason Gunthorpe,
Leon Romanovsky, open list
Simplify allocation by eliminating one. No longer need to kfree pages
separately.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/infiniband/hw/ocrdma/ocrdma.h | 2 +-
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 15 +++------------
2 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h
index 5584b781e2e8..da2deae6857b 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma.h
@@ -190,8 +190,8 @@ struct ocrdma_mr {
struct ib_mr ibmr;
struct ib_umem *umem;
struct ocrdma_hw_mr hwmr;
- u64 *pages;
u32 npages;
+ u64 pages[];
};
struct ocrdma_stats {
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 7383b67e1723..eb922b9b0075 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -910,7 +910,6 @@ int ocrdma_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
(void) ocrdma_mbx_dealloc_lkey(dev, mr->hwmr.fr_mr, mr->hwmr.lkey);
- kfree(mr->pages);
ocrdma_free_mr_pbl_tbl(dev, &mr->hwmr);
/* it could be user registered memory. */
@@ -2908,19 +2907,13 @@ struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,
if (max_num_sg > dev->attr.max_pages_per_frmr)
return ERR_PTR(-EINVAL);
- mr = kzalloc_obj(*mr);
+ mr = kzalloc_flex(*mr, pages, max_num_sg);
if (!mr)
return ERR_PTR(-ENOMEM);
- mr->pages = kzalloc_objs(*mr->pages, max_num_sg);
- if (!mr->pages) {
- status = -ENOMEM;
- goto pl_err;
- }
-
status = ocrdma_get_pbl_info(dev, mr, max_num_sg);
if (status)
- goto pbl_err;
+ goto pl_err;
mr->hwmr.fr_mr = 1;
mr->hwmr.remote_rd = 0;
mr->hwmr.remote_wr = 0;
@@ -2929,7 +2922,7 @@ struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,
mr->hwmr.mw_bind = 0;
status = ocrdma_build_pbl_tbl(dev, &mr->hwmr);
if (status)
- goto pbl_err;
+ goto pl_err;
status = ocrdma_reg_mr(dev, &mr->hwmr, pd->id, 0);
if (status)
goto mbx_err;
@@ -2940,8 +2933,6 @@ struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,
return &mr->ibmr;
mbx_err:
ocrdma_free_mr_pbl_tbl(dev, &mr->hwmr);
-pbl_err:
- kfree(mr->pages);
pl_err:
kfree(mr);
return ERR_PTR(-ENOMEM);
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] RDMA/ocrdma: kzalloc_objs to kzalloc_flex
2026-03-08 20:14 [PATCH] RDMA/ocrdma: kzalloc_objs to kzalloc_flex Rosen Penev
@ 2026-03-10 10:23 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-03-10 10:23 UTC (permalink / raw)
To: linux-rdma, Rosen Penev
Cc: Selvin Xavier, linux-hardening, gustavoars, Jason Gunthorpe,
linux-kernel
On Sun, 08 Mar 2026 13:14:19 -0700, Rosen Penev wrote:
> Simplify allocation by eliminating one. No longer need to kfree pages
> separately.
Applied, thanks!
[1/1] RDMA/ocrdma: kzalloc_objs to kzalloc_flex
https://git.kernel.org/rdma/rdma/c/353b3bbdb2c43f
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-10 10:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-08 20:14 [PATCH] RDMA/ocrdma: kzalloc_objs to kzalloc_flex Rosen Penev
2026-03-10 10:23 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox