[PATCH rdma-next 3/4] RDMA/bnxt_re: Replace kcalloc() with kzalloc_objs()

Leon Romanovsky posted 4 patches 2 weeks, 5 days ago
[PATCH rdma-next 3/4] RDMA/bnxt_re: Replace kcalloc() with kzalloc_objs()
Posted by Leon Romanovsky 2 weeks, 5 days ago
From: Leon Romanovsky <leonro@nvidia.com>

New code should use kzalloc_objs() instead of kcalloc(). Update the driver
accordingly.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index cb53dfdf69bab..1aee4fec137eb 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -3486,8 +3486,7 @@ int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 	cq->qplib_cq.cq_handle = (u64)(unsigned long)(&cq->qplib_cq);
 
 	cq->max_cql = attr->cqe + 1;
-	cq->cql = kcalloc(cq->max_cql, sizeof(struct bnxt_qplib_cqe),
-			  GFP_KERNEL);
+	cq->cql = kzalloc_objs(struct bnxt_qplib_cqe, cq->max_cql);
 	if (!cq->cql)
 		return -ENOMEM;
 
@@ -4413,7 +4412,7 @@ struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type type,
 	mr->ib_mr.lkey = mr->qplib_mr.lkey;
 	mr->ib_mr.rkey = mr->ib_mr.lkey;
 
-	mr->pages = kcalloc(max_num_sg, sizeof(u64), GFP_KERNEL);
+	mr->pages = kzalloc_objs(u64, max_num_sg);
 	if (!mr->pages) {
 		rc = -ENOMEM;
 		goto fail;

-- 
2.53.0
Re: [PATCH rdma-next 3/4] RDMA/bnxt_re: Replace kcalloc() with kzalloc_objs()
Posted by Selvin Xavier 2 weeks ago
On Wed, Mar 18, 2026 at 3:39 PM Leon Romanovsky <leon@kernel.org> wrote:
>
> From: Leon Romanovsky <leonro@nvidia.com>
>
> New code should use kzalloc_objs() instead of kcalloc(). Update the driver
> accordingly.
>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Selvin Xavier <selvin.xavier@broadcom.com>
> ---
>  drivers/infiniband/hw/bnxt_re/ib_verbs.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index cb53dfdf69bab..1aee4fec137eb 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> @@ -3486,8 +3486,7 @@ int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
>         cq->qplib_cq.cq_handle = (u64)(unsigned long)(&cq->qplib_cq);
>
>         cq->max_cql = attr->cqe + 1;
> -       cq->cql = kcalloc(cq->max_cql, sizeof(struct bnxt_qplib_cqe),
> -                         GFP_KERNEL);
> +       cq->cql = kzalloc_objs(struct bnxt_qplib_cqe, cq->max_cql);
>         if (!cq->cql)
>                 return -ENOMEM;
>
> @@ -4413,7 +4412,7 @@ struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type type,
>         mr->ib_mr.lkey = mr->qplib_mr.lkey;
>         mr->ib_mr.rkey = mr->ib_mr.lkey;
>
> -       mr->pages = kcalloc(max_num_sg, sizeof(u64), GFP_KERNEL);
> +       mr->pages = kzalloc_objs(u64, max_num_sg);
>         if (!mr->pages) {
>                 rc = -ENOMEM;
>                 goto fail;
>
> --
> 2.53.0
>