* Re: [PATCH] RDMA/hns: ZERO_OR_NULL_PTR macro overdetection [not found] <20250603015936.103600-1-l1138897701@163.com> @ 2025-06-03 2:16 ` Junxian Huang 2025-06-04 10:46 ` Leon Romanovsky 0 siblings, 1 reply; 2+ messages in thread From: Junxian Huang @ 2025-06-03 2:16 UTC (permalink / raw) To: luoqing; +Cc: tangchengchang, jgg, leon, luoqing, linux-rdma On 2025/6/3 9:59, luoqing wrote: > From: luoqing <luoqing@kylinos.cn> > > sizeof(xx) these variable values' return values cannot be 0. > For memory allocation requests of non-zero length, > there is no need to check other return values; > it is sufficient to only verify that it is not null. > > Signed-off-by: luoqing <luoqing@kylinos.cn> For future patches, please add RDMA maillist. Thanks, Reviewed-by: Junxian Huang <huangjunxian6@hisilicon.com> > --- > drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++--- > drivers/infiniband/hw/hns/hns_roce_qp.c | 4 ++-- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > index 160e8927d364..65884f63fc7c 100644 > --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > @@ -2613,7 +2613,7 @@ static struct ib_pd *free_mr_init_pd(struct hns_roce_dev *hr_dev) > struct ib_pd *pd; > > hr_pd = kzalloc(sizeof(*hr_pd), GFP_KERNEL); > - if (ZERO_OR_NULL_PTR(hr_pd)) > + if (!hr_pd) > return NULL; > pd = &hr_pd->ibpd; > pd->device = ibdev; > @@ -2644,7 +2644,7 @@ static struct ib_cq *free_mr_init_cq(struct hns_roce_dev *hr_dev) > cq_init_attr.cqe = HNS_ROCE_FREE_MR_USED_CQE_NUM; > > hr_cq = kzalloc(sizeof(*hr_cq), GFP_KERNEL); > - if (ZERO_OR_NULL_PTR(hr_cq)) > + if (!hr_cq) > return NULL; > > cq = &hr_cq->ib_cq; > @@ -2677,7 +2677,7 @@ static int free_mr_init_qp(struct hns_roce_dev *hr_dev, struct ib_cq *cq, > int ret; > > hr_qp = kzalloc(sizeof(*hr_qp), GFP_KERNEL); > - if (ZERO_OR_NULL_PTR(hr_qp)) > + if (!hr_qp) > return -ENOMEM; > > qp = &hr_qp->ibqp; > diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c > index 9f376a2232b0..6ff1b8ce580c 100644 > --- a/drivers/infiniband/hw/hns/hns_roce_qp.c > +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c > @@ -1003,14 +1003,14 @@ static int alloc_kernel_wrid(struct hns_roce_dev *hr_dev, > int ret; > > sq_wrid = kcalloc(hr_qp->sq.wqe_cnt, sizeof(u64), GFP_KERNEL); > - if (ZERO_OR_NULL_PTR(sq_wrid)) { > + if (!sq_wrid) { > ibdev_err(ibdev, "failed to alloc SQ wrid.\n"); > return -ENOMEM; > } > > if (hr_qp->rq.wqe_cnt) { > rq_wrid = kcalloc(hr_qp->rq.wqe_cnt, sizeof(u64), GFP_KERNEL); > - if (ZERO_OR_NULL_PTR(rq_wrid)) { > + if (!rq_wrid) { > ibdev_err(ibdev, "failed to alloc RQ wrid.\n"); > ret = -ENOMEM; > goto err_sq; ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] RDMA/hns: ZERO_OR_NULL_PTR macro overdetection 2025-06-03 2:16 ` [PATCH] RDMA/hns: ZERO_OR_NULL_PTR macro overdetection Junxian Huang @ 2025-06-04 10:46 ` Leon Romanovsky 0 siblings, 0 replies; 2+ messages in thread From: Leon Romanovsky @ 2025-06-04 10:46 UTC (permalink / raw) To: Junxian Huang; +Cc: luoqing, tangchengchang, jgg, luoqing, linux-rdma On Tue, Jun 03, 2025 at 10:16:21AM +0800, Junxian Huang wrote: > > > On 2025/6/3 9:59, luoqing wrote: > > From: luoqing <luoqing@kylinos.cn> > > > > sizeof(xx) these variable values' return values cannot be 0. > > For memory allocation requests of non-zero length, > > there is no need to check other return values; > > it is sufficient to only verify that it is not null. > > > > Signed-off-by: luoqing <luoqing@kylinos.cn> > > For future patches, please add RDMA maillist. For this patch too. Please resend. Thanks > > Thanks, > Reviewed-by: Junxian Huang <huangjunxian6@hisilicon.com> > > > --- > > drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++--- > > drivers/infiniband/hw/hns/hns_roce_qp.c | 4 ++-- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > > index 160e8927d364..65884f63fc7c 100644 > > --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > > @@ -2613,7 +2613,7 @@ static struct ib_pd *free_mr_init_pd(struct hns_roce_dev *hr_dev) > > struct ib_pd *pd; > > > > hr_pd = kzalloc(sizeof(*hr_pd), GFP_KERNEL); > > - if (ZERO_OR_NULL_PTR(hr_pd)) > > + if (!hr_pd) > > return NULL; > > pd = &hr_pd->ibpd; > > pd->device = ibdev; > > @@ -2644,7 +2644,7 @@ static struct ib_cq *free_mr_init_cq(struct hns_roce_dev *hr_dev) > > cq_init_attr.cqe = HNS_ROCE_FREE_MR_USED_CQE_NUM; > > > > hr_cq = kzalloc(sizeof(*hr_cq), GFP_KERNEL); > > - if (ZERO_OR_NULL_PTR(hr_cq)) > > + if (!hr_cq) > > return NULL; > > > > cq = &hr_cq->ib_cq; > > @@ -2677,7 +2677,7 @@ static int free_mr_init_qp(struct hns_roce_dev *hr_dev, struct ib_cq *cq, > > int ret; > > > > hr_qp = kzalloc(sizeof(*hr_qp), GFP_KERNEL); > > - if (ZERO_OR_NULL_PTR(hr_qp)) > > + if (!hr_qp) > > return -ENOMEM; > > > > qp = &hr_qp->ibqp; > > diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c > > index 9f376a2232b0..6ff1b8ce580c 100644 > > --- a/drivers/infiniband/hw/hns/hns_roce_qp.c > > +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c > > @@ -1003,14 +1003,14 @@ static int alloc_kernel_wrid(struct hns_roce_dev *hr_dev, > > int ret; > > > > sq_wrid = kcalloc(hr_qp->sq.wqe_cnt, sizeof(u64), GFP_KERNEL); > > - if (ZERO_OR_NULL_PTR(sq_wrid)) { > > + if (!sq_wrid) { > > ibdev_err(ibdev, "failed to alloc SQ wrid.\n"); > > return -ENOMEM; > > } > > > > if (hr_qp->rq.wqe_cnt) { > > rq_wrid = kcalloc(hr_qp->rq.wqe_cnt, sizeof(u64), GFP_KERNEL); > > - if (ZERO_OR_NULL_PTR(rq_wrid)) { > > + if (!rq_wrid) { > > ibdev_err(ibdev, "failed to alloc RQ wrid.\n"); > > ret = -ENOMEM; > > goto err_sq; ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-04 10:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250603015936.103600-1-l1138897701@163.com>
2025-06-03 2:16 ` [PATCH] RDMA/hns: ZERO_OR_NULL_PTR macro overdetection Junxian Huang
2025-06-04 10:46 ` Leon Romanovsky
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox