RDMA/hns: ZERO_OR_NULL_PTR macro overdetection
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>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user