]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/hns: ZERO_OR_NULL_PTR macro overdetection
authorluoqing <luoqing@kylinos.cn>
Thu, 5 Jun 2025 03:49:18 +0000 (11:49 +0800)
committerLeon Romanovsky <leon@kernel.org>
Thu, 12 Jun 2025 08:12:59 +0000 (04:12 -0400)
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>
Link: https://patch.msgid.link/20250605034918.242682-1-l1138897701@163.com
Reviewed-by: Junxian Huang <huangjunxian6@hisilicon.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_qp.c

index fa8747656f25fe638dc3b74c36c7b808b8652710..764404017ee409f9d91a167671ec60a7ac7b7b4d 100644 (file)
@@ -2627,7 +2627,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;
@@ -2658,7 +2658,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;
@@ -2691,7 +2691,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;
index 9f376a2232b0930a84246fe89b250fd35c7ad7ef..6ff1b8ce580c502312645021b0fefc20a180b7ce 100644 (file)
@@ -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;