From: Leon Romanovsky <leon@kernel.org>
To: Junxian Huang <huangjunxian6@hisilicon.com>
Cc: luoqing <l1138897701@163.com>,
tangchengchang@huawei.com, jgg@ziepe.ca, luoqing@kylinos.cn,
linux-rdma <linux-rdma@vger.kernel.org>
Subject: Re: [PATCH] RDMA/hns: ZERO_OR_NULL_PTR macro overdetection
Date: Wed, 4 Jun 2025 13:46:52 +0300 [thread overview]
Message-ID: <20250604104652.GE7435@unreal> (raw)
In-Reply-To: <bfa2366e-6876-ad51-ce07-fe98a46f7833@hisilicon.com>
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;
prev parent reply other threads:[~2025-06-04 10:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 message]
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=20250604104652.GE7435@unreal \
--to=leon@kernel.org \
--cc=huangjunxian6@hisilicon.com \
--cc=jgg@ziepe.ca \
--cc=l1138897701@163.com \
--cc=linux-rdma@vger.kernel.org \
--cc=luoqing@kylinos.cn \
--cc=tangchengchang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.